
obj/user/init:     file format elf32-i386


Disassembly of section .text:

00800020 <_start>:
// starts us running when we are initially loaded into a new environment.
.text
.globl _start
_start:
	// See if we were started with arguments on the stack
	cmpl $USTACKTOP, %esp
  800020:	81 fc 00 e0 bf ee    	cmp    $0xeebfe000,%esp
	jne args_exist
  800026:	75 04                	jne    80002c <args_exist>

	// If not, push dummy argc/argv arguments.
	// This happens when we are loaded by the kernel,
	// because the kernel does not know about passing arguments.
	pushl $0
  800028:	6a 00                	push   $0x0
	pushl $0
  80002a:	6a 00                	push   $0x0

0080002c <args_exist>:

args_exist:
	call libmain
  80002c:	e8 b3 03 00 00       	call   8003e4 <libmain>
1:	jmp 1b
  800031:	eb fe                	jmp    800031 <args_exist+0x5>
	...

00800040 <sum>:

char bss[6000];

int
sum(const char *s, int n)
{
  800040:	55                   	push   %ebp
  800041:	89 e5                	mov    %esp,%ebp
  800043:	56                   	push   %esi
  800044:	53                   	push   %ebx
  800045:	8b 75 08             	mov    0x8(%ebp),%esi
  800048:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	int i, tot = 0;
	for (i = 0; i < n; i++)
  80004b:	b8 00 00 00 00       	mov    $0x0,%eax
  800050:	ba 00 00 00 00       	mov    $0x0,%edx
  800055:	85 db                	test   %ebx,%ebx
  800057:	7e 10                	jle    800069 <sum+0x29>
		tot ^= i * s[i];
  800059:	0f be 0c 16          	movsbl (%esi,%edx,1),%ecx
  80005d:	0f af ca             	imul   %edx,%ecx
  800060:	31 c8                	xor    %ecx,%eax

int
sum(const char *s, int n)
{
	int i, tot = 0;
	for (i = 0; i < n; i++)
  800062:	83 c2 01             	add    $0x1,%edx
  800065:	39 da                	cmp    %ebx,%edx
  800067:	75 f0                	jne    800059 <sum+0x19>
		tot ^= i * s[i];
	return tot;
}
  800069:	5b                   	pop    %ebx
  80006a:	5e                   	pop    %esi
  80006b:	5d                   	pop    %ebp
  80006c:	c3                   	ret    

0080006d <umain>:
		
void
umain(int argc, char **argv)
{
  80006d:	55                   	push   %ebp
  80006e:	89 e5                	mov    %esp,%ebp
  800070:	57                   	push   %edi
  800071:	56                   	push   %esi
  800072:	53                   	push   %ebx
  800073:	83 ec 1c             	sub    $0x1c,%esp
  800076:	8b 7d 08             	mov    0x8(%ebp),%edi
  800079:	8b 75 0c             	mov    0xc(%ebp),%esi
	int i, r, x, want;

	cprintf("init: running\n");
  80007c:	c7 04 24 60 30 80 00 	movl   $0x803060,(%esp)
  800083:	e8 8d 04 00 00       	call   800515 <cprintf>

	want = 0xf989e;
	if ((x = sum((char*)&data, sizeof data)) != want)
  800088:	c7 44 24 04 70 17 00 	movl   $0x1770,0x4(%esp)
  80008f:	00 
  800090:	c7 04 24 00 70 80 00 	movl   $0x807000,(%esp)
  800097:	e8 a4 ff ff ff       	call   800040 <sum>
  80009c:	3d 9e 98 0f 00       	cmp    $0xf989e,%eax
  8000a1:	74 1a                	je     8000bd <umain+0x50>
		cprintf("init: data is not initialized: got sum %08x wanted %08x\n",
  8000a3:	c7 44 24 08 9e 98 0f 	movl   $0xf989e,0x8(%esp)
  8000aa:	00 
  8000ab:	89 44 24 04          	mov    %eax,0x4(%esp)
  8000af:	c7 04 24 28 31 80 00 	movl   $0x803128,(%esp)
  8000b6:	e8 5a 04 00 00       	call   800515 <cprintf>
  8000bb:	eb 0c                	jmp    8000c9 <umain+0x5c>
			x, want);
	else
		cprintf("init: data seems okay\n");
  8000bd:	c7 04 24 6f 30 80 00 	movl   $0x80306f,(%esp)
  8000c4:	e8 4c 04 00 00       	call   800515 <cprintf>
	if ((x = sum(bss, sizeof bss)) != 0)
  8000c9:	c7 44 24 04 70 17 00 	movl   $0x1770,0x4(%esp)
  8000d0:	00 
  8000d1:	c7 04 24 00 88 80 00 	movl   $0x808800,(%esp)
  8000d8:	e8 63 ff ff ff       	call   800040 <sum>
  8000dd:	85 c0                	test   %eax,%eax
  8000df:	74 12                	je     8000f3 <umain+0x86>
		cprintf("bss is not initialized: wanted sum 0 got %08x\n", x);
  8000e1:	89 44 24 04          	mov    %eax,0x4(%esp)
  8000e5:	c7 04 24 64 31 80 00 	movl   $0x803164,(%esp)
  8000ec:	e8 24 04 00 00       	call   800515 <cprintf>
  8000f1:	eb 0c                	jmp    8000ff <umain+0x92>
	else
		cprintf("init: bss seems okay\n");
  8000f3:	c7 04 24 86 30 80 00 	movl   $0x803086,(%esp)
  8000fa:	e8 16 04 00 00       	call   800515 <cprintf>

	cprintf("init: args:");
  8000ff:	c7 04 24 9c 30 80 00 	movl   $0x80309c,(%esp)
  800106:	e8 0a 04 00 00       	call   800515 <cprintf>
	for (i = 0; i < argc; i++)
  80010b:	85 ff                	test   %edi,%edi
  80010d:	7e 1f                	jle    80012e <umain+0xc1>
  80010f:	bb 00 00 00 00       	mov    $0x0,%ebx
		cprintf(" '%s'", argv[i]);
  800114:	8b 04 9e             	mov    (%esi,%ebx,4),%eax
  800117:	89 44 24 04          	mov    %eax,0x4(%esp)
  80011b:	c7 04 24 a8 30 80 00 	movl   $0x8030a8,(%esp)
  800122:	e8 ee 03 00 00       	call   800515 <cprintf>
		cprintf("bss is not initialized: wanted sum 0 got %08x\n", x);
	else
		cprintf("init: bss seems okay\n");

	cprintf("init: args:");
	for (i = 0; i < argc; i++)
  800127:	83 c3 01             	add    $0x1,%ebx
  80012a:	39 df                	cmp    %ebx,%edi
  80012c:	7f e6                	jg     800114 <umain+0xa7>
		cprintf(" '%s'", argv[i]);
	cprintf("\n");
  80012e:	c7 04 24 e3 36 80 00 	movl   $0x8036e3,(%esp)
  800135:	e8 db 03 00 00       	call   800515 <cprintf>

	cprintf("init: running sh\n");
  80013a:	c7 04 24 ae 30 80 00 	movl   $0x8030ae,(%esp)
  800141:	e8 cf 03 00 00       	call   800515 <cprintf>

	// being run directly from kernel, so no file descriptors open yet
	close(0);
  800146:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  80014d:	e8 da 17 00 00       	call   80192c <close>
	if ((r = opencons()) < 0)
  800152:	e8 d0 01 00 00       	call   800327 <opencons>
  800157:	85 c0                	test   %eax,%eax
  800159:	79 20                	jns    80017b <umain+0x10e>
		panic("opencons: %e", r);
  80015b:	89 44 24 0c          	mov    %eax,0xc(%esp)
  80015f:	c7 44 24 08 c0 30 80 	movl   $0x8030c0,0x8(%esp)
  800166:	00 
  800167:	c7 44 24 04 32 00 00 	movl   $0x32,0x4(%esp)
  80016e:	00 
  80016f:	c7 04 24 cd 30 80 00 	movl   $0x8030cd,(%esp)
  800176:	e8 d5 02 00 00       	call   800450 <_panic>
	if (r != 0)
  80017b:	85 c0                	test   %eax,%eax
  80017d:	74 20                	je     80019f <umain+0x132>
		panic("first opencons used fd %d", r);
  80017f:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800183:	c7 44 24 08 d9 30 80 	movl   $0x8030d9,0x8(%esp)
  80018a:	00 
  80018b:	c7 44 24 04 34 00 00 	movl   $0x34,0x4(%esp)
  800192:	00 
  800193:	c7 04 24 cd 30 80 00 	movl   $0x8030cd,(%esp)
  80019a:	e8 b1 02 00 00       	call   800450 <_panic>
	if ((r = dup(0, 1)) < 0)
  80019f:	c7 44 24 04 01 00 00 	movl   $0x1,0x4(%esp)
  8001a6:	00 
  8001a7:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8001ae:	e8 18 18 00 00       	call   8019cb <dup>
  8001b3:	85 c0                	test   %eax,%eax
  8001b5:	79 20                	jns    8001d7 <umain+0x16a>
		panic("dup: %e", r);
  8001b7:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8001bb:	c7 44 24 08 f3 30 80 	movl   $0x8030f3,0x8(%esp)
  8001c2:	00 
  8001c3:	c7 44 24 04 36 00 00 	movl   $0x36,0x4(%esp)
  8001ca:	00 
  8001cb:	c7 04 24 cd 30 80 00 	movl   $0x8030cd,(%esp)
  8001d2:	e8 79 02 00 00       	call   800450 <_panic>
	while (1) {
		cprintf("init: starting sh\n");
  8001d7:	c7 04 24 fb 30 80 00 	movl   $0x8030fb,(%esp)
  8001de:	e8 32 03 00 00       	call   800515 <cprintf>
		r = spawnl("/sh", "sh", (char*)0);
  8001e3:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  8001ea:	00 
  8001eb:	c7 44 24 04 0f 31 80 	movl   $0x80310f,0x4(%esp)
  8001f2:	00 
  8001f3:	c7 04 24 0e 31 80 00 	movl   $0x80310e,(%esp)
  8001fa:	e8 a5 21 00 00       	call   8023a4 <spawnl>
		if (r < 0) {
  8001ff:	85 c0                	test   %eax,%eax
  800201:	79 12                	jns    800215 <umain+0x1a8>
			cprintf("init: spawn sh: %e\n", r);
  800203:	89 44 24 04          	mov    %eax,0x4(%esp)
  800207:	c7 04 24 12 31 80 00 	movl   $0x803112,(%esp)
  80020e:	e8 02 03 00 00       	call   800515 <cprintf>
			continue;
  800213:	eb c2                	jmp    8001d7 <umain+0x16a>
		}
		wait(r);
  800215:	89 04 24             	mov    %eax,(%esp)
  800218:	e8 57 2a 00 00       	call   802c74 <wait>
  80021d:	8d 76 00             	lea    0x0(%esi),%esi
  800220:	eb b5                	jmp    8001d7 <umain+0x16a>
	...

00800230 <devcons_close>:
	return tot;
}

static int
devcons_close(struct Fd *fd)
{
  800230:	55                   	push   %ebp
  800231:	89 e5                	mov    %esp,%ebp
	USED(fd);

	return 0;
}
  800233:	b8 00 00 00 00       	mov    $0x0,%eax
  800238:	5d                   	pop    %ebp
  800239:	c3                   	ret    

0080023a <devcons_stat>:

static int
devcons_stat(struct Fd *fd, struct Stat *stat)
{
  80023a:	55                   	push   %ebp
  80023b:	89 e5                	mov    %esp,%ebp
  80023d:	83 ec 18             	sub    $0x18,%esp
	strcpy(stat->st_name, "<cons>");
  800240:	c7 44 24 04 93 31 80 	movl   $0x803193,0x4(%esp)
  800247:	00 
  800248:	8b 45 0c             	mov    0xc(%ebp),%eax
  80024b:	89 04 24             	mov    %eax,(%esp)
  80024e:	e8 97 09 00 00       	call   800bea <strcpy>
	return 0;
}
  800253:	b8 00 00 00 00       	mov    $0x0,%eax
  800258:	c9                   	leave  
  800259:	c3                   	ret    

0080025a <devcons_write>:
	return 1;
}

static ssize_t
devcons_write(struct Fd *fd, const void *vbuf, size_t n)
{
  80025a:	55                   	push   %ebp
  80025b:	89 e5                	mov    %esp,%ebp
  80025d:	57                   	push   %edi
  80025e:	56                   	push   %esi
  80025f:	53                   	push   %ebx
  800260:	81 ec 9c 00 00 00    	sub    $0x9c,%esp
	int tot, m;
	char buf[128];

	// mistake: have to nul-terminate arg to sys_cputs, 
	// so we have to copy vbuf into buf in chunks and nul-terminate.
	for (tot = 0; tot < n; tot += m) {
  800266:	b8 00 00 00 00       	mov    $0x0,%eax
  80026b:	be 00 00 00 00       	mov    $0x0,%esi
  800270:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  800274:	74 41                	je     8002b7 <devcons_write+0x5d>
		m = n - tot;
		if (m > sizeof(buf) - 1)
			m = sizeof(buf) - 1;
		memmove(buf, (char*)vbuf + tot, m);
  800276:	8d bd 68 ff ff ff    	lea    -0x98(%ebp),%edi
	char buf[128];

	// mistake: have to nul-terminate arg to sys_cputs, 
	// so we have to copy vbuf into buf in chunks and nul-terminate.
	for (tot = 0; tot < n; tot += m) {
		m = n - tot;
  80027c:	8b 5d 10             	mov    0x10(%ebp),%ebx
  80027f:	29 c3                	sub    %eax,%ebx
		if (m > sizeof(buf) - 1)
  800281:	81 fb 80 00 00 00    	cmp    $0x80,%ebx
  800287:	ba 7f 00 00 00       	mov    $0x7f,%edx
  80028c:	0f 43 da             	cmovae %edx,%ebx
			m = sizeof(buf) - 1;
		memmove(buf, (char*)vbuf + tot, m);
  80028f:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  800293:	03 45 0c             	add    0xc(%ebp),%eax
  800296:	89 44 24 04          	mov    %eax,0x4(%esp)
  80029a:	89 3c 24             	mov    %edi,(%esp)
  80029d:	e8 03 0b 00 00       	call   800da5 <memmove>
		sys_cputs(buf, m);
  8002a2:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  8002a6:	89 3c 24             	mov    %edi,(%esp)
  8002a9:	e8 32 0d 00 00       	call   800fe0 <sys_cputs>
	int tot, m;
	char buf[128];

	// mistake: have to nul-terminate arg to sys_cputs, 
	// so we have to copy vbuf into buf in chunks and nul-terminate.
	for (tot = 0; tot < n; tot += m) {
  8002ae:	01 de                	add    %ebx,%esi
  8002b0:	89 f0                	mov    %esi,%eax
  8002b2:	3b 75 10             	cmp    0x10(%ebp),%esi
  8002b5:	72 c5                	jb     80027c <devcons_write+0x22>
			m = sizeof(buf) - 1;
		memmove(buf, (char*)vbuf + tot, m);
		sys_cputs(buf, m);
	}
	return tot;
}
  8002b7:	89 f0                	mov    %esi,%eax
  8002b9:	81 c4 9c 00 00 00    	add    $0x9c,%esp
  8002bf:	5b                   	pop    %ebx
  8002c0:	5e                   	pop    %esi
  8002c1:	5f                   	pop    %edi
  8002c2:	5d                   	pop    %ebp
  8002c3:	c3                   	ret    

008002c4 <cputchar>:
#include <inc/string.h>
#include <inc/lib.h>

void
cputchar(int ch)
{
  8002c4:	55                   	push   %ebp
  8002c5:	89 e5                	mov    %esp,%ebp
  8002c7:	83 ec 28             	sub    $0x28,%esp
	char c = ch;
  8002ca:	8b 45 08             	mov    0x8(%ebp),%eax
  8002cd:	88 45 f7             	mov    %al,-0x9(%ebp)

	// Unlike standard Unix's putchar,
	// the cputchar function _always_ outputs to the system console.
	sys_cputs(&c, 1);
  8002d0:	c7 44 24 04 01 00 00 	movl   $0x1,0x4(%esp)
  8002d7:	00 
  8002d8:	8d 45 f7             	lea    -0x9(%ebp),%eax
  8002db:	89 04 24             	mov    %eax,(%esp)
  8002de:	e8 fd 0c 00 00       	call   800fe0 <sys_cputs>
}
  8002e3:	c9                   	leave  
  8002e4:	c3                   	ret    

008002e5 <devcons_read>:
	return fd2num(fd);
}

static ssize_t
devcons_read(struct Fd *fd, void *vbuf, size_t n)
{
  8002e5:	55                   	push   %ebp
  8002e6:	89 e5                	mov    %esp,%ebp
  8002e8:	83 ec 08             	sub    $0x8,%esp
	int c;

	if (n == 0)
  8002eb:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  8002ef:	75 07                	jne    8002f8 <devcons_read+0x13>
  8002f1:	eb 2d                	jmp    800320 <devcons_read+0x3b>
		return 0;
	while ((c = sys_cgetc()) == 0)
		sys_yield();
  8002f3:	e8 ad 10 00 00       	call   8013a5 <sys_yield>
{
	int c;

	if (n == 0)
		return 0;
	while ((c = sys_cgetc()) == 0)
  8002f8:	90                   	nop
  8002f9:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
  800300:	e8 a7 0c 00 00       	call   800fac <sys_cgetc>
  800305:	85 c0                	test   %eax,%eax
  800307:	74 ea                	je     8002f3 <devcons_read+0xe>
  800309:	89 c2                	mov    %eax,%edx
		sys_yield();
	if (c < 0)
  80030b:	85 c0                	test   %eax,%eax
  80030d:	78 16                	js     800325 <devcons_read+0x40>
		return c;
	if (c == 0x04)	// ctl-d is eof
  80030f:	83 f8 04             	cmp    $0x4,%eax
  800312:	74 0c                	je     800320 <devcons_read+0x3b>
		return 0;
	*(char*)vbuf = c;
  800314:	8b 45 0c             	mov    0xc(%ebp),%eax
  800317:	88 10                	mov    %dl,(%eax)
  800319:	b8 01 00 00 00       	mov    $0x1,%eax
	return 1;
  80031e:	eb 05                	jmp    800325 <devcons_read+0x40>
  800320:	b8 00 00 00 00       	mov    $0x0,%eax
}
  800325:	c9                   	leave  
  800326:	c3                   	ret    

00800327 <opencons>:
	return fd->fd_dev_id == devcons.dev_id;
}

int
opencons(void)
{
  800327:	55                   	push   %ebp
  800328:	89 e5                	mov    %esp,%ebp
  80032a:	83 ec 28             	sub    $0x28,%esp
	int r;
	struct Fd* fd;

	if ((r = fd_alloc(&fd)) < 0)
  80032d:	8d 45 f4             	lea    -0xc(%ebp),%eax
  800330:	89 04 24             	mov    %eax,(%esp)
  800333:	e8 63 11 00 00       	call   80149b <fd_alloc>
  800338:	85 c0                	test   %eax,%eax
  80033a:	78 3f                	js     80037b <opencons+0x54>
		return r;
	if ((r = sys_page_alloc(0, fd, PTE_P|PTE_U|PTE_W|PTE_SHARE)) < 0)
  80033c:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  800343:	00 
  800344:	8b 45 f4             	mov    -0xc(%ebp),%eax
  800347:	89 44 24 04          	mov    %eax,0x4(%esp)
  80034b:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  800352:	e8 ef 0f 00 00       	call   801346 <sys_page_alloc>
  800357:	85 c0                	test   %eax,%eax
  800359:	78 20                	js     80037b <opencons+0x54>
		return r;
	fd->fd_dev_id = devcons.dev_id;
  80035b:	8b 15 70 87 80 00    	mov    0x808770,%edx
  800361:	8b 45 f4             	mov    -0xc(%ebp),%eax
  800364:	89 10                	mov    %edx,(%eax)
	fd->fd_omode = O_RDWR;
  800366:	8b 45 f4             	mov    -0xc(%ebp),%eax
  800369:	c7 40 08 02 00 00 00 	movl   $0x2,0x8(%eax)
	return fd2num(fd);
  800370:	8b 45 f4             	mov    -0xc(%ebp),%eax
  800373:	89 04 24             	mov    %eax,(%esp)
  800376:	e8 f5 10 00 00       	call   801470 <fd2num>
}
  80037b:	c9                   	leave  
  80037c:	c3                   	ret    

0080037d <iscons>:
	.dev_stat =	devcons_stat
};

int
iscons(int fdnum)
{
  80037d:	55                   	push   %ebp
  80037e:	89 e5                	mov    %esp,%ebp
  800380:	83 ec 28             	sub    $0x28,%esp
	int r;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0)
  800383:	8d 45 f4             	lea    -0xc(%ebp),%eax
  800386:	89 44 24 04          	mov    %eax,0x4(%esp)
  80038a:	8b 45 08             	mov    0x8(%ebp),%eax
  80038d:	89 04 24             	mov    %eax,(%esp)
  800390:	e8 78 11 00 00       	call   80150d <fd_lookup>
  800395:	85 c0                	test   %eax,%eax
  800397:	78 11                	js     8003aa <iscons+0x2d>
		return r;
	return fd->fd_dev_id == devcons.dev_id;
  800399:	8b 45 f4             	mov    -0xc(%ebp),%eax
  80039c:	8b 00                	mov    (%eax),%eax
  80039e:	3b 05 70 87 80 00    	cmp    0x808770,%eax
  8003a4:	0f 94 c0             	sete   %al
  8003a7:	0f b6 c0             	movzbl %al,%eax
}
  8003aa:	c9                   	leave  
  8003ab:	c3                   	ret    

008003ac <getchar>:
	sys_cputs(&c, 1);
}

int
getchar(void)
{
  8003ac:	55                   	push   %ebp
  8003ad:	89 e5                	mov    %esp,%ebp
  8003af:	83 ec 28             	sub    $0x28,%esp
	int r;

	// JOS does, however, support standard _input_ redirection,
	// allowing the user to redirect script files to the shell and such.
	// getchar() reads a character from file descriptor 0.
	r = read(0, &c, 1);
  8003b2:	c7 44 24 08 01 00 00 	movl   $0x1,0x8(%esp)
  8003b9:	00 
  8003ba:	8d 45 f7             	lea    -0x9(%ebp),%eax
  8003bd:	89 44 24 04          	mov    %eax,0x4(%esp)
  8003c1:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8003c8:	e8 a6 13 00 00       	call   801773 <read>
	if (r < 0)
  8003cd:	85 c0                	test   %eax,%eax
  8003cf:	78 0f                	js     8003e0 <getchar+0x34>
		return r;
	if (r < 1)
  8003d1:	85 c0                	test   %eax,%eax
  8003d3:	7f 07                	jg     8003dc <getchar+0x30>
  8003d5:	b8 f8 ff ff ff       	mov    $0xfffffff8,%eax
  8003da:	eb 04                	jmp    8003e0 <getchar+0x34>
		return -E_EOF;
	return c;
  8003dc:	0f b6 45 f7          	movzbl -0x9(%ebp),%eax
}
  8003e0:	c9                   	leave  
  8003e1:	c3                   	ret    
	...

008003e4 <libmain>:
volatile struct Env *env;
char *binaryname = "(PROGRAM NAME UNKNOWN)";

void
libmain(int argc, char **argv)
{
  8003e4:	55                   	push   %ebp
  8003e5:	89 e5                	mov    %esp,%ebp
  8003e7:	83 ec 18             	sub    $0x18,%esp
  8003ea:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  8003ed:	89 75 fc             	mov    %esi,-0x4(%ebp)
  8003f0:	8b 75 08             	mov    0x8(%ebp),%esi
  8003f3:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	// set env to point at our env structure in envs[].
	// LAB 3: Your code here.
  envid_t envid   = sys_getenvid();
  8003f6:	e8 de 0f 00 00       	call   8013d9 <sys_getenvid>
	env = &envs [ENVX(envid)];
  8003fb:	25 ff 03 00 00       	and    $0x3ff,%eax
  800400:	6b c0 7c             	imul   $0x7c,%eax,%eax
  800403:	05 00 00 c0 ee       	add    $0xeec00000,%eax
  800408:	a3 70 9f 80 00       	mov    %eax,0x809f70

	// save the name of the program so that panic() can use it
	if (argc > 0)
  80040d:	85 f6                	test   %esi,%esi
  80040f:	7e 07                	jle    800418 <libmain+0x34>
		binaryname = argv[0];
  800411:	8b 03                	mov    (%ebx),%eax
  800413:	a3 8c 87 80 00       	mov    %eax,0x80878c

	// call user main routine
	umain(argc, argv);
  800418:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  80041c:	89 34 24             	mov    %esi,(%esp)
  80041f:	e8 49 fc ff ff       	call   80006d <umain>

	// exit gracefully
	exit();
  800424:	e8 0b 00 00 00       	call   800434 <exit>
}
  800429:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  80042c:	8b 75 fc             	mov    -0x4(%ebp),%esi
  80042f:	89 ec                	mov    %ebp,%esp
  800431:	5d                   	pop    %ebp
  800432:	c3                   	ret    
	...

00800434 <exit>:

#include <inc/lib.h>

void
exit(void)
{
  800434:	55                   	push   %ebp
  800435:	89 e5                	mov    %esp,%ebp
  800437:	83 ec 18             	sub    $0x18,%esp
	close_all();
  80043a:	e8 6a 15 00 00       	call   8019a9 <close_all>
	sys_env_destroy(0);
  80043f:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  800446:	e8 c2 0f 00 00       	call   80140d <sys_env_destroy>
}
  80044b:	c9                   	leave  
  80044c:	c3                   	ret    
  80044d:	00 00                	add    %al,(%eax)
	...

00800450 <_panic>:
 * It prints "panic: <message>", then causes a breakpoint exception,
 * which causes JOS to enter the JOS kernel monitor.
 */
void
_panic(const char *file, int line, const char *fmt,...)
{
  800450:	55                   	push   %ebp
  800451:	89 e5                	mov    %esp,%ebp
  800453:	53                   	push   %ebx
  800454:	83 ec 14             	sub    $0x14,%esp
 * Panic is called on unresolvable fatal errors.
 * It prints "panic: <message>", then causes a breakpoint exception,
 * which causes JOS to enter the JOS kernel monitor.
 */
void
_panic(const char *file, int line, const char *fmt,...)
  800457:	8d 5d 14             	lea    0x14(%ebp),%ebx
	va_list ap;

	va_start(ap, fmt);

	// Print the panic message
	if (argv0)
  80045a:	a1 74 9f 80 00       	mov    0x809f74,%eax
  80045f:	85 c0                	test   %eax,%eax
  800461:	74 10                	je     800473 <_panic+0x23>
		cprintf("%s: ", argv0);
  800463:	89 44 24 04          	mov    %eax,0x4(%esp)
  800467:	c7 04 24 b6 31 80 00 	movl   $0x8031b6,(%esp)
  80046e:	e8 a2 00 00 00       	call   800515 <cprintf>
	cprintf("user panic in %s at %s:%d: ", binaryname, file, line);
  800473:	8b 45 0c             	mov    0xc(%ebp),%eax
  800476:	89 44 24 0c          	mov    %eax,0xc(%esp)
  80047a:	8b 45 08             	mov    0x8(%ebp),%eax
  80047d:	89 44 24 08          	mov    %eax,0x8(%esp)
  800481:	a1 8c 87 80 00       	mov    0x80878c,%eax
  800486:	89 44 24 04          	mov    %eax,0x4(%esp)
  80048a:	c7 04 24 bb 31 80 00 	movl   $0x8031bb,(%esp)
  800491:	e8 7f 00 00 00       	call   800515 <cprintf>
	vcprintf(fmt, ap);
  800496:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  80049a:	8b 45 10             	mov    0x10(%ebp),%eax
  80049d:	89 04 24             	mov    %eax,(%esp)
  8004a0:	e8 0f 00 00 00       	call   8004b4 <vcprintf>
	cprintf("\n");
  8004a5:	c7 04 24 e3 36 80 00 	movl   $0x8036e3,(%esp)
  8004ac:	e8 64 00 00 00       	call   800515 <cprintf>

	// Cause a breakpoint exception
	while (1)
		asm volatile("int3");
  8004b1:	cc                   	int3   
  8004b2:	eb fd                	jmp    8004b1 <_panic+0x61>

008004b4 <vcprintf>:
	b->cnt++;
}

int
vcprintf(const char *fmt, va_list ap)
{
  8004b4:	55                   	push   %ebp
  8004b5:	89 e5                	mov    %esp,%ebp
  8004b7:	81 ec 28 01 00 00    	sub    $0x128,%esp
	struct printbuf b;

	b.idx = 0;
  8004bd:	c7 85 f0 fe ff ff 00 	movl   $0x0,-0x110(%ebp)
  8004c4:	00 00 00 
	b.cnt = 0;
  8004c7:	c7 85 f4 fe ff ff 00 	movl   $0x0,-0x10c(%ebp)
  8004ce:	00 00 00 
	vprintfmt((void*)putch, &b, fmt, ap);
  8004d1:	8b 45 0c             	mov    0xc(%ebp),%eax
  8004d4:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8004d8:	8b 45 08             	mov    0x8(%ebp),%eax
  8004db:	89 44 24 08          	mov    %eax,0x8(%esp)
  8004df:	8d 85 f0 fe ff ff    	lea    -0x110(%ebp),%eax
  8004e5:	89 44 24 04          	mov    %eax,0x4(%esp)
  8004e9:	c7 04 24 2f 05 80 00 	movl   $0x80052f,(%esp)
  8004f0:	e8 d8 01 00 00       	call   8006cd <vprintfmt>
	sys_cputs(b.buf, b.idx);
  8004f5:	8b 85 f0 fe ff ff    	mov    -0x110(%ebp),%eax
  8004fb:	89 44 24 04          	mov    %eax,0x4(%esp)
  8004ff:	8d 85 f8 fe ff ff    	lea    -0x108(%ebp),%eax
  800505:	89 04 24             	mov    %eax,(%esp)
  800508:	e8 d3 0a 00 00       	call   800fe0 <sys_cputs>

	return b.cnt;
}
  80050d:	8b 85 f4 fe ff ff    	mov    -0x10c(%ebp),%eax
  800513:	c9                   	leave  
  800514:	c3                   	ret    

00800515 <cprintf>:

int
cprintf(const char *fmt, ...)
{
  800515:	55                   	push   %ebp
  800516:	89 e5                	mov    %esp,%ebp
  800518:	83 ec 18             	sub    $0x18,%esp

	return b.cnt;
}

int
cprintf(const char *fmt, ...)
  80051b:	8d 45 0c             	lea    0xc(%ebp),%eax
{
	va_list ap;
	int cnt;

	va_start(ap, fmt);
	cnt = vcprintf(fmt, ap);
  80051e:	89 44 24 04          	mov    %eax,0x4(%esp)
  800522:	8b 45 08             	mov    0x8(%ebp),%eax
  800525:	89 04 24             	mov    %eax,(%esp)
  800528:	e8 87 ff ff ff       	call   8004b4 <vcprintf>
	va_end(ap);

	return cnt;
}
  80052d:	c9                   	leave  
  80052e:	c3                   	ret    

0080052f <putch>:
};


static void
putch(int ch, struct printbuf *b)
{
  80052f:	55                   	push   %ebp
  800530:	89 e5                	mov    %esp,%ebp
  800532:	53                   	push   %ebx
  800533:	83 ec 14             	sub    $0x14,%esp
  800536:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	b->buf[b->idx++] = ch;
  800539:	8b 03                	mov    (%ebx),%eax
  80053b:	8b 55 08             	mov    0x8(%ebp),%edx
  80053e:	88 54 03 08          	mov    %dl,0x8(%ebx,%eax,1)
  800542:	83 c0 01             	add    $0x1,%eax
  800545:	89 03                	mov    %eax,(%ebx)
	if (b->idx == 256-1) {
  800547:	3d ff 00 00 00       	cmp    $0xff,%eax
  80054c:	75 19                	jne    800567 <putch+0x38>
		sys_cputs(b->buf, b->idx);
  80054e:	c7 44 24 04 ff 00 00 	movl   $0xff,0x4(%esp)
  800555:	00 
  800556:	8d 43 08             	lea    0x8(%ebx),%eax
  800559:	89 04 24             	mov    %eax,(%esp)
  80055c:	e8 7f 0a 00 00       	call   800fe0 <sys_cputs>
		b->idx = 0;
  800561:	c7 03 00 00 00 00    	movl   $0x0,(%ebx)
	}
	b->cnt++;
  800567:	83 43 04 01          	addl   $0x1,0x4(%ebx)
}
  80056b:	83 c4 14             	add    $0x14,%esp
  80056e:	5b                   	pop    %ebx
  80056f:	5d                   	pop    %ebp
  800570:	c3                   	ret    
	...

00800580 <printnum>:
 * using specified putch function and associated pointer putdat.
 */
static void
printnum(void (*putch)(int, void*), void *putdat,
	 unsigned long long num, unsigned base, int width, int padc)
{
  800580:	55                   	push   %ebp
  800581:	89 e5                	mov    %esp,%ebp
  800583:	57                   	push   %edi
  800584:	56                   	push   %esi
  800585:	53                   	push   %ebx
  800586:	83 ec 4c             	sub    $0x4c,%esp
  800589:	89 45 e4             	mov    %eax,-0x1c(%ebp)
  80058c:	89 d6                	mov    %edx,%esi
  80058e:	8b 45 08             	mov    0x8(%ebp),%eax
  800591:	89 45 d8             	mov    %eax,-0x28(%ebp)
  800594:	8b 55 0c             	mov    0xc(%ebp),%edx
  800597:	89 55 e0             	mov    %edx,-0x20(%ebp)
  80059a:	8b 45 10             	mov    0x10(%ebp),%eax
  80059d:	8b 5d 14             	mov    0x14(%ebp),%ebx
  8005a0:	8b 7d 18             	mov    0x18(%ebp),%edi
	// first recursively print all preceding (more significant) digits
	if (num >= base) {
  8005a3:	89 45 dc             	mov    %eax,-0x24(%ebp)
  8005a6:	b9 00 00 00 00       	mov    $0x0,%ecx
  8005ab:	39 d1                	cmp    %edx,%ecx
  8005ad:	72 15                	jb     8005c4 <printnum+0x44>
  8005af:	77 07                	ja     8005b8 <printnum+0x38>
  8005b1:	8b 55 d8             	mov    -0x28(%ebp),%edx
  8005b4:	39 d0                	cmp    %edx,%eax
  8005b6:	76 0c                	jbe    8005c4 <printnum+0x44>
		printnum(putch, putdat, num / base, base, width - 1, padc);
	} else {
		// print any needed pad characters before first digit
		while (--width > 0)
  8005b8:	83 eb 01             	sub    $0x1,%ebx
  8005bb:	85 db                	test   %ebx,%ebx
  8005bd:	8d 76 00             	lea    0x0(%esi),%esi
  8005c0:	7f 61                	jg     800623 <printnum+0xa3>
  8005c2:	eb 70                	jmp    800634 <printnum+0xb4>
printnum(void (*putch)(int, void*), void *putdat,
	 unsigned long long num, unsigned base, int width, int padc)
{
	// first recursively print all preceding (more significant) digits
	if (num >= base) {
		printnum(putch, putdat, num / base, base, width - 1, padc);
  8005c4:	89 7c 24 10          	mov    %edi,0x10(%esp)
  8005c8:	83 eb 01             	sub    $0x1,%ebx
  8005cb:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  8005cf:	89 44 24 08          	mov    %eax,0x8(%esp)
  8005d3:	8b 4c 24 08          	mov    0x8(%esp),%ecx
  8005d7:	8b 5c 24 0c          	mov    0xc(%esp),%ebx
  8005db:	89 4d d0             	mov    %ecx,-0x30(%ebp)
  8005de:	89 5d d4             	mov    %ebx,-0x2c(%ebp)
  8005e1:	8b 5d dc             	mov    -0x24(%ebp),%ebx
  8005e4:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  8005e8:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  8005ef:	00 
  8005f0:	8b 45 d8             	mov    -0x28(%ebp),%eax
  8005f3:	89 04 24             	mov    %eax,(%esp)
  8005f6:	8b 55 e0             	mov    -0x20(%ebp),%edx
  8005f9:	89 54 24 04          	mov    %edx,0x4(%esp)
  8005fd:	e8 ee 27 00 00       	call   802df0 <__udivdi3>
  800602:	8b 4d d0             	mov    -0x30(%ebp),%ecx
  800605:	8b 5d d4             	mov    -0x2c(%ebp),%ebx
  800608:	89 4c 24 08          	mov    %ecx,0x8(%esp)
  80060c:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  800610:	89 04 24             	mov    %eax,(%esp)
  800613:	89 54 24 04          	mov    %edx,0x4(%esp)
  800617:	89 f2                	mov    %esi,%edx
  800619:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  80061c:	e8 5f ff ff ff       	call   800580 <printnum>
  800621:	eb 11                	jmp    800634 <printnum+0xb4>
	} else {
		// print any needed pad characters before first digit
		while (--width > 0)
			putch(padc, putdat);
  800623:	89 74 24 04          	mov    %esi,0x4(%esp)
  800627:	89 3c 24             	mov    %edi,(%esp)
  80062a:	ff 55 e4             	call   *-0x1c(%ebp)
	// first recursively print all preceding (more significant) digits
	if (num >= base) {
		printnum(putch, putdat, num / base, base, width - 1, padc);
	} else {
		// print any needed pad characters before first digit
		while (--width > 0)
  80062d:	83 eb 01             	sub    $0x1,%ebx
  800630:	85 db                	test   %ebx,%ebx
  800632:	7f ef                	jg     800623 <printnum+0xa3>
			putch(padc, putdat);
	}

	// then print this (the least significant) digit
	putch("0123456789abcdef"[num % base], putdat);
  800634:	89 74 24 04          	mov    %esi,0x4(%esp)
  800638:	8b 74 24 04          	mov    0x4(%esp),%esi
  80063c:	8b 45 dc             	mov    -0x24(%ebp),%eax
  80063f:	89 44 24 08          	mov    %eax,0x8(%esp)
  800643:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  80064a:	00 
  80064b:	8b 55 d8             	mov    -0x28(%ebp),%edx
  80064e:	89 14 24             	mov    %edx,(%esp)
  800651:	8b 4d e0             	mov    -0x20(%ebp),%ecx
  800654:	89 4c 24 04          	mov    %ecx,0x4(%esp)
  800658:	e8 c3 28 00 00       	call   802f20 <__umoddi3>
  80065d:	89 74 24 04          	mov    %esi,0x4(%esp)
  800661:	0f be 80 d7 31 80 00 	movsbl 0x8031d7(%eax),%eax
  800668:	89 04 24             	mov    %eax,(%esp)
  80066b:	ff 55 e4             	call   *-0x1c(%ebp)
}
  80066e:	83 c4 4c             	add    $0x4c,%esp
  800671:	5b                   	pop    %ebx
  800672:	5e                   	pop    %esi
  800673:	5f                   	pop    %edi
  800674:	5d                   	pop    %ebp
  800675:	c3                   	ret    

00800676 <getuint>:

// Get an unsigned int of various possible sizes from a varargs list,
// depending on the lflag parameter.
static unsigned long long
getuint(va_list *ap, int lflag)
{
  800676:	55                   	push   %ebp
  800677:	89 e5                	mov    %esp,%ebp
	if (lflag >= 2)
  800679:	83 fa 01             	cmp    $0x1,%edx
  80067c:	7e 0e                	jle    80068c <getuint+0x16>
		return va_arg(*ap, unsigned long long);
  80067e:	8b 10                	mov    (%eax),%edx
  800680:	8d 4a 08             	lea    0x8(%edx),%ecx
  800683:	89 08                	mov    %ecx,(%eax)
  800685:	8b 02                	mov    (%edx),%eax
  800687:	8b 52 04             	mov    0x4(%edx),%edx
  80068a:	eb 22                	jmp    8006ae <getuint+0x38>
	else if (lflag)
  80068c:	85 d2                	test   %edx,%edx
  80068e:	74 10                	je     8006a0 <getuint+0x2a>
		return va_arg(*ap, unsigned long);
  800690:	8b 10                	mov    (%eax),%edx
  800692:	8d 4a 04             	lea    0x4(%edx),%ecx
  800695:	89 08                	mov    %ecx,(%eax)
  800697:	8b 02                	mov    (%edx),%eax
  800699:	ba 00 00 00 00       	mov    $0x0,%edx
  80069e:	eb 0e                	jmp    8006ae <getuint+0x38>
	else
		return va_arg(*ap, unsigned int);
  8006a0:	8b 10                	mov    (%eax),%edx
  8006a2:	8d 4a 04             	lea    0x4(%edx),%ecx
  8006a5:	89 08                	mov    %ecx,(%eax)
  8006a7:	8b 02                	mov    (%edx),%eax
  8006a9:	ba 00 00 00 00       	mov    $0x0,%edx
}
  8006ae:	5d                   	pop    %ebp
  8006af:	c3                   	ret    

008006b0 <sprintputch>:
	int cnt;
};

static void
sprintputch(int ch, struct sprintbuf *b)
{
  8006b0:	55                   	push   %ebp
  8006b1:	89 e5                	mov    %esp,%ebp
  8006b3:	8b 45 0c             	mov    0xc(%ebp),%eax
	b->cnt++;
  8006b6:	83 40 08 01          	addl   $0x1,0x8(%eax)
	if (b->buf < b->ebuf)
  8006ba:	8b 10                	mov    (%eax),%edx
  8006bc:	3b 50 04             	cmp    0x4(%eax),%edx
  8006bf:	73 0a                	jae    8006cb <sprintputch+0x1b>
		*b->buf++ = ch;
  8006c1:	8b 4d 08             	mov    0x8(%ebp),%ecx
  8006c4:	88 0a                	mov    %cl,(%edx)
  8006c6:	83 c2 01             	add    $0x1,%edx
  8006c9:	89 10                	mov    %edx,(%eax)
}
  8006cb:	5d                   	pop    %ebp
  8006cc:	c3                   	ret    

008006cd <vprintfmt>:
// Main function to format and print a string.
void printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...);

void
vprintfmt(void (*putch)(int, void*), void *putdat, const char *fmt, va_list ap)
{
  8006cd:	55                   	push   %ebp
  8006ce:	89 e5                	mov    %esp,%ebp
  8006d0:	57                   	push   %edi
  8006d1:	56                   	push   %esi
  8006d2:	53                   	push   %ebx
  8006d3:	83 ec 5c             	sub    $0x5c,%esp
  8006d6:	8b 7d 08             	mov    0x8(%ebp),%edi
  8006d9:	8b 75 0c             	mov    0xc(%ebp),%esi
  8006dc:	8b 5d 10             	mov    0x10(%ebp),%ebx
		case '#':
			altflag = 1;
			goto reswitch;

		process_precision:
			if (width < 0)
  8006df:	c7 45 c8 ff ff ff ff 	movl   $0xffffffff,-0x38(%ebp)
  8006e6:	eb 11                	jmp    8006f9 <vprintfmt+0x2c>
	int base, lflag, width, precision, altflag;
	char padc;

	while (1) {
		while ((ch = *(unsigned char *) fmt++) != '%') {
			if (ch == '\0')
  8006e8:	85 c0                	test   %eax,%eax
  8006ea:	0f 84 f9 03 00 00    	je     800ae9 <vprintfmt+0x41c>
				return;
			putch(ch, putdat);
  8006f0:	89 74 24 04          	mov    %esi,0x4(%esp)
  8006f4:	89 04 24             	mov    %eax,(%esp)
  8006f7:	ff d7                	call   *%edi
	unsigned long long num;
	int base, lflag, width, precision, altflag;
	char padc;

	while (1) {
		while ((ch = *(unsigned char *) fmt++) != '%') {
  8006f9:	0f b6 03             	movzbl (%ebx),%eax
  8006fc:	83 c3 01             	add    $0x1,%ebx
  8006ff:	83 f8 25             	cmp    $0x25,%eax
  800702:	75 e4                	jne    8006e8 <vprintfmt+0x1b>
  800704:	c6 45 d4 20          	movb   $0x20,-0x2c(%ebp)
  800708:	c7 45 d8 00 00 00 00 	movl   $0x0,-0x28(%ebp)
  80070f:	c7 45 d0 ff ff ff ff 	movl   $0xffffffff,-0x30(%ebp)
  800716:	c7 45 e4 ff ff ff ff 	movl   $0xffffffff,-0x1c(%ebp)
  80071d:	b9 00 00 00 00       	mov    $0x0,%ecx
  800722:	eb 06                	jmp    80072a <vprintfmt+0x5d>
  800724:	c6 45 d4 2d          	movb   $0x2d,-0x2c(%ebp)
  800728:	89 c3                	mov    %eax,%ebx
		width = -1;
		precision = -1;
		lflag = 0;
		altflag = 0;
	reswitch:
		switch (ch = *(unsigned char *) fmt++) {
  80072a:	0f b6 13             	movzbl (%ebx),%edx
  80072d:	0f b6 c2             	movzbl %dl,%eax
  800730:	89 45 e0             	mov    %eax,-0x20(%ebp)
  800733:	8d 43 01             	lea    0x1(%ebx),%eax
  800736:	83 ea 23             	sub    $0x23,%edx
  800739:	80 fa 55             	cmp    $0x55,%dl
  80073c:	0f 87 8a 03 00 00    	ja     800acc <vprintfmt+0x3ff>
  800742:	0f b6 d2             	movzbl %dl,%edx
  800745:	ff 24 95 20 33 80 00 	jmp    *0x803320(,%edx,4)
  80074c:	c6 45 d4 30          	movb   $0x30,-0x2c(%ebp)
  800750:	eb d6                	jmp    800728 <vprintfmt+0x5b>
		case '6':
		case '7':
		case '8':
		case '9':
			for (precision = 0; ; ++fmt) {
				precision = precision * 10 + ch - '0';
  800752:	8b 55 e0             	mov    -0x20(%ebp),%edx
  800755:	83 ea 30             	sub    $0x30,%edx
  800758:	89 55 d0             	mov    %edx,-0x30(%ebp)
				ch = *fmt;
  80075b:	0f be 10             	movsbl (%eax),%edx
				if (ch < '0' || ch > '9')
  80075e:	8d 5a d0             	lea    -0x30(%edx),%ebx
  800761:	83 fb 09             	cmp    $0x9,%ebx
  800764:	77 54                	ja     8007ba <vprintfmt+0xed>
  800766:	89 4d e0             	mov    %ecx,-0x20(%ebp)
  800769:	8b 4d d0             	mov    -0x30(%ebp),%ecx
		case '5':
		case '6':
		case '7':
		case '8':
		case '9':
			for (precision = 0; ; ++fmt) {
  80076c:	83 c0 01             	add    $0x1,%eax
				precision = precision * 10 + ch - '0';
  80076f:	8d 0c 89             	lea    (%ecx,%ecx,4),%ecx
  800772:	8d 4c 4a d0          	lea    -0x30(%edx,%ecx,2),%ecx
				ch = *fmt;
  800776:	0f be 10             	movsbl (%eax),%edx
				if (ch < '0' || ch > '9')
  800779:	8d 5a d0             	lea    -0x30(%edx),%ebx
  80077c:	83 fb 09             	cmp    $0x9,%ebx
  80077f:	76 eb                	jbe    80076c <vprintfmt+0x9f>
  800781:	89 4d d0             	mov    %ecx,-0x30(%ebp)
  800784:	8b 4d e0             	mov    -0x20(%ebp),%ecx
  800787:	eb 31                	jmp    8007ba <vprintfmt+0xed>
					break;
			}
			goto process_precision;

		case '*':
			precision = va_arg(ap, int);
  800789:	8b 55 14             	mov    0x14(%ebp),%edx
  80078c:	8d 5a 04             	lea    0x4(%edx),%ebx
  80078f:	89 5d 14             	mov    %ebx,0x14(%ebp)
  800792:	8b 12                	mov    (%edx),%edx
  800794:	89 55 d0             	mov    %edx,-0x30(%ebp)
			goto process_precision;
  800797:	eb 21                	jmp    8007ba <vprintfmt+0xed>

		case '.':
			if (width < 0)
  800799:	83 7d e4 00          	cmpl   $0x0,-0x1c(%ebp)
  80079d:	ba 00 00 00 00       	mov    $0x0,%edx
  8007a2:	0f 49 55 e4          	cmovns -0x1c(%ebp),%edx
  8007a6:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  8007a9:	e9 7a ff ff ff       	jmp    800728 <vprintfmt+0x5b>
  8007ae:	c7 45 d8 01 00 00 00 	movl   $0x1,-0x28(%ebp)
				width = 0;
			goto reswitch;

		case '#':
			altflag = 1;
			goto reswitch;
  8007b5:	e9 6e ff ff ff       	jmp    800728 <vprintfmt+0x5b>

		process_precision:
			if (width < 0)
  8007ba:	83 7d e4 00          	cmpl   $0x0,-0x1c(%ebp)
  8007be:	0f 89 64 ff ff ff    	jns    800728 <vprintfmt+0x5b>
  8007c4:	8b 55 d0             	mov    -0x30(%ebp),%edx
  8007c7:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  8007ca:	8b 55 c8             	mov    -0x38(%ebp),%edx
  8007cd:	89 55 d0             	mov    %edx,-0x30(%ebp)
  8007d0:	e9 53 ff ff ff       	jmp    800728 <vprintfmt+0x5b>
				width = precision, precision = -1;
			goto reswitch;

		// long flag (doubled for long long)
		case 'l':
			lflag++;
  8007d5:	83 c1 01             	add    $0x1,%ecx
			goto reswitch;
  8007d8:	e9 4b ff ff ff       	jmp    800728 <vprintfmt+0x5b>
  8007dd:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// character
		case 'c':
			putch(va_arg(ap, int), putdat);
  8007e0:	8b 45 14             	mov    0x14(%ebp),%eax
  8007e3:	8d 50 04             	lea    0x4(%eax),%edx
  8007e6:	89 55 14             	mov    %edx,0x14(%ebp)
  8007e9:	89 74 24 04          	mov    %esi,0x4(%esp)
  8007ed:	8b 00                	mov    (%eax),%eax
  8007ef:	89 04 24             	mov    %eax,(%esp)
  8007f2:	ff d7                	call   *%edi
  8007f4:	8b 5d cc             	mov    -0x34(%ebp),%ebx
			break;
  8007f7:	e9 fd fe ff ff       	jmp    8006f9 <vprintfmt+0x2c>
  8007fc:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// error message
		case 'e':
			err = va_arg(ap, int);
  8007ff:	8b 45 14             	mov    0x14(%ebp),%eax
  800802:	8d 50 04             	lea    0x4(%eax),%edx
  800805:	89 55 14             	mov    %edx,0x14(%ebp)
  800808:	8b 00                	mov    (%eax),%eax
  80080a:	89 c2                	mov    %eax,%edx
  80080c:	c1 fa 1f             	sar    $0x1f,%edx
  80080f:	31 d0                	xor    %edx,%eax
  800811:	29 d0                	sub    %edx,%eax
			if (err < 0)
				err = -err;
			if (err > MAXERROR || (p = error_string[err]) == NULL)
  800813:	83 f8 12             	cmp    $0x12,%eax
  800816:	7f 0b                	jg     800823 <vprintfmt+0x156>
  800818:	8b 14 85 80 34 80 00 	mov    0x803480(,%eax,4),%edx
  80081f:	85 d2                	test   %edx,%edx
  800821:	75 20                	jne    800843 <vprintfmt+0x176>
				printfmt(putch, putdat, "error %d", err);
  800823:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800827:	c7 44 24 08 e8 31 80 	movl   $0x8031e8,0x8(%esp)
  80082e:	00 
  80082f:	89 74 24 04          	mov    %esi,0x4(%esp)
  800833:	89 3c 24             	mov    %edi,(%esp)
  800836:	e8 36 03 00 00       	call   800b71 <printfmt>
  80083b:	8b 5d cc             	mov    -0x34(%ebp),%ebx
		// error message
		case 'e':
			err = va_arg(ap, int);
			if (err < 0)
				err = -err;
			if (err > MAXERROR || (p = error_string[err]) == NULL)
  80083e:	e9 b6 fe ff ff       	jmp    8006f9 <vprintfmt+0x2c>
				printfmt(putch, putdat, "error %d", err);
			else
				printfmt(putch, putdat, "%s", p);
  800843:	89 54 24 0c          	mov    %edx,0xc(%esp)
  800847:	c7 44 24 08 d4 35 80 	movl   $0x8035d4,0x8(%esp)
  80084e:	00 
  80084f:	89 74 24 04          	mov    %esi,0x4(%esp)
  800853:	89 3c 24             	mov    %edi,(%esp)
  800856:	e8 16 03 00 00       	call   800b71 <printfmt>
  80085b:	8b 5d cc             	mov    -0x34(%ebp),%ebx
  80085e:	e9 96 fe ff ff       	jmp    8006f9 <vprintfmt+0x2c>
  800863:	89 45 cc             	mov    %eax,-0x34(%ebp)
  800866:	89 c3                	mov    %eax,%ebx
  800868:	8b 4d d0             	mov    -0x30(%ebp),%ecx
  80086b:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  80086e:	89 45 c4             	mov    %eax,-0x3c(%ebp)
			break;

		// string
		case 's':
			if ((p = va_arg(ap, char *)) == NULL)
  800871:	8b 45 14             	mov    0x14(%ebp),%eax
  800874:	8d 50 04             	lea    0x4(%eax),%edx
  800877:	89 55 14             	mov    %edx,0x14(%ebp)
  80087a:	8b 00                	mov    (%eax),%eax
  80087c:	89 45 e0             	mov    %eax,-0x20(%ebp)
  80087f:	85 c0                	test   %eax,%eax
  800881:	b8 f1 31 80 00       	mov    $0x8031f1,%eax
  800886:	0f 45 45 e0          	cmovne -0x20(%ebp),%eax
  80088a:	89 45 e0             	mov    %eax,-0x20(%ebp)
				p = "(null)";
			if (width > 0 && padc != '-')
  80088d:	83 7d c4 00          	cmpl   $0x0,-0x3c(%ebp)
  800891:	7e 06                	jle    800899 <vprintfmt+0x1cc>
  800893:	80 7d d4 2d          	cmpb   $0x2d,-0x2c(%ebp)
  800897:	75 13                	jne    8008ac <vprintfmt+0x1df>
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
  800899:	8b 55 e0             	mov    -0x20(%ebp),%edx
  80089c:	0f be 02             	movsbl (%edx),%eax
  80089f:	85 c0                	test   %eax,%eax
  8008a1:	0f 85 9b 00 00 00    	jne    800942 <vprintfmt+0x275>
  8008a7:	e9 88 00 00 00       	jmp    800934 <vprintfmt+0x267>
		// string
		case 's':
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
  8008ac:	89 4c 24 04          	mov    %ecx,0x4(%esp)
  8008b0:	8b 4d e0             	mov    -0x20(%ebp),%ecx
  8008b3:	89 0c 24             	mov    %ecx,(%esp)
  8008b6:	e8 00 03 00 00       	call   800bbb <strnlen>
  8008bb:	8b 55 c4             	mov    -0x3c(%ebp),%edx
  8008be:	29 c2                	sub    %eax,%edx
  8008c0:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  8008c3:	85 d2                	test   %edx,%edx
  8008c5:	7e d2                	jle    800899 <vprintfmt+0x1cc>
					putch(padc, putdat);
  8008c7:	0f be 4d d4          	movsbl -0x2c(%ebp),%ecx
  8008cb:	89 4d d4             	mov    %ecx,-0x2c(%ebp)
  8008ce:	89 5d c4             	mov    %ebx,-0x3c(%ebp)
  8008d1:	89 d3                	mov    %edx,%ebx
  8008d3:	89 74 24 04          	mov    %esi,0x4(%esp)
  8008d7:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  8008da:	89 04 24             	mov    %eax,(%esp)
  8008dd:	ff d7                	call   *%edi
		// string
		case 's':
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
  8008df:	83 eb 01             	sub    $0x1,%ebx
  8008e2:	85 db                	test   %ebx,%ebx
  8008e4:	7f ed                	jg     8008d3 <vprintfmt+0x206>
  8008e6:	8b 5d c4             	mov    -0x3c(%ebp),%ebx
  8008e9:	c7 45 e4 00 00 00 00 	movl   $0x0,-0x1c(%ebp)
  8008f0:	eb a7                	jmp    800899 <vprintfmt+0x1cc>
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
				if (altflag && (ch < ' ' || ch > '~'))
  8008f2:	83 7d d8 00          	cmpl   $0x0,-0x28(%ebp)
  8008f6:	74 1a                	je     800912 <vprintfmt+0x245>
  8008f8:	8d 50 e0             	lea    -0x20(%eax),%edx
  8008fb:	83 fa 5e             	cmp    $0x5e,%edx
  8008fe:	76 12                	jbe    800912 <vprintfmt+0x245>
					putch('?', putdat);
  800900:	89 7c 24 04          	mov    %edi,0x4(%esp)
  800904:	c7 04 24 3f 00 00 00 	movl   $0x3f,(%esp)
  80090b:	ff 55 e0             	call   *-0x20(%ebp)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
				if (altflag && (ch < ' ' || ch > '~'))
  80090e:	66 90                	xchg   %ax,%ax
  800910:	eb 0a                	jmp    80091c <vprintfmt+0x24f>
					putch('?', putdat);
				else
					putch(ch, putdat);
  800912:	89 7c 24 04          	mov    %edi,0x4(%esp)
  800916:	89 04 24             	mov    %eax,(%esp)
  800919:	ff 55 e0             	call   *-0x20(%ebp)
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
  80091c:	83 6d e4 01          	subl   $0x1,-0x1c(%ebp)
  800920:	0f be 03             	movsbl (%ebx),%eax
  800923:	85 c0                	test   %eax,%eax
  800925:	74 05                	je     80092c <vprintfmt+0x25f>
  800927:	83 c3 01             	add    $0x1,%ebx
  80092a:	eb 29                	jmp    800955 <vprintfmt+0x288>
  80092c:	89 fe                	mov    %edi,%esi
  80092e:	8b 7d e0             	mov    -0x20(%ebp),%edi
  800931:	8b 5d d0             	mov    -0x30(%ebp),%ebx
				if (altflag && (ch < ' ' || ch > '~'))
					putch('?', putdat);
				else
					putch(ch, putdat);
			for (; width > 0; width--)
  800934:	83 7d e4 00          	cmpl   $0x0,-0x1c(%ebp)
  800938:	7f 2e                	jg     800968 <vprintfmt+0x29b>
  80093a:	8b 5d cc             	mov    -0x34(%ebp),%ebx
  80093d:	e9 b7 fd ff ff       	jmp    8006f9 <vprintfmt+0x2c>
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
  800942:	8b 55 e0             	mov    -0x20(%ebp),%edx
  800945:	83 c2 01             	add    $0x1,%edx
  800948:	89 7d e0             	mov    %edi,-0x20(%ebp)
  80094b:	89 f7                	mov    %esi,%edi
  80094d:	8b 75 d0             	mov    -0x30(%ebp),%esi
  800950:	89 5d d0             	mov    %ebx,-0x30(%ebp)
  800953:	89 d3                	mov    %edx,%ebx
  800955:	85 f6                	test   %esi,%esi
  800957:	78 99                	js     8008f2 <vprintfmt+0x225>
  800959:	83 ee 01             	sub    $0x1,%esi
  80095c:	79 94                	jns    8008f2 <vprintfmt+0x225>
  80095e:	89 fe                	mov    %edi,%esi
  800960:	8b 7d e0             	mov    -0x20(%ebp),%edi
  800963:	8b 5d d0             	mov    -0x30(%ebp),%ebx
  800966:	eb cc                	jmp    800934 <vprintfmt+0x267>
  800968:	89 5d d8             	mov    %ebx,-0x28(%ebp)
  80096b:	8b 5d e4             	mov    -0x1c(%ebp),%ebx
				if (altflag && (ch < ' ' || ch > '~'))
					putch('?', putdat);
				else
					putch(ch, putdat);
			for (; width > 0; width--)
				putch(' ', putdat);
  80096e:	89 74 24 04          	mov    %esi,0x4(%esp)
  800972:	c7 04 24 20 00 00 00 	movl   $0x20,(%esp)
  800979:	ff d7                	call   *%edi
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
				if (altflag && (ch < ' ' || ch > '~'))
					putch('?', putdat);
				else
					putch(ch, putdat);
			for (; width > 0; width--)
  80097b:	83 eb 01             	sub    $0x1,%ebx
  80097e:	85 db                	test   %ebx,%ebx
  800980:	7f ec                	jg     80096e <vprintfmt+0x2a1>
  800982:	8b 5d d8             	mov    -0x28(%ebp),%ebx
  800985:	e9 6f fd ff ff       	jmp    8006f9 <vprintfmt+0x2c>
  80098a:	89 45 cc             	mov    %eax,-0x34(%ebp)
// Same as getuint but signed - can't use getuint
// because of sign extension
static long long
getint(va_list *ap, int lflag)
{
	if (lflag >= 2)
  80098d:	83 f9 01             	cmp    $0x1,%ecx
  800990:	7e 16                	jle    8009a8 <vprintfmt+0x2db>
		return va_arg(*ap, long long);
  800992:	8b 45 14             	mov    0x14(%ebp),%eax
  800995:	8d 50 08             	lea    0x8(%eax),%edx
  800998:	89 55 14             	mov    %edx,0x14(%ebp)
  80099b:	8b 10                	mov    (%eax),%edx
  80099d:	8b 48 04             	mov    0x4(%eax),%ecx
  8009a0:	89 55 d8             	mov    %edx,-0x28(%ebp)
  8009a3:	89 4d dc             	mov    %ecx,-0x24(%ebp)
  8009a6:	eb 32                	jmp    8009da <vprintfmt+0x30d>
	else if (lflag)
  8009a8:	85 c9                	test   %ecx,%ecx
  8009aa:	74 18                	je     8009c4 <vprintfmt+0x2f7>
		return va_arg(*ap, long);
  8009ac:	8b 45 14             	mov    0x14(%ebp),%eax
  8009af:	8d 50 04             	lea    0x4(%eax),%edx
  8009b2:	89 55 14             	mov    %edx,0x14(%ebp)
  8009b5:	8b 00                	mov    (%eax),%eax
  8009b7:	89 45 d8             	mov    %eax,-0x28(%ebp)
  8009ba:	89 c1                	mov    %eax,%ecx
  8009bc:	c1 f9 1f             	sar    $0x1f,%ecx
  8009bf:	89 4d dc             	mov    %ecx,-0x24(%ebp)
  8009c2:	eb 16                	jmp    8009da <vprintfmt+0x30d>
	else
		return va_arg(*ap, int);
  8009c4:	8b 45 14             	mov    0x14(%ebp),%eax
  8009c7:	8d 50 04             	lea    0x4(%eax),%edx
  8009ca:	89 55 14             	mov    %edx,0x14(%ebp)
  8009cd:	8b 00                	mov    (%eax),%eax
  8009cf:	89 45 d8             	mov    %eax,-0x28(%ebp)
  8009d2:	89 c2                	mov    %eax,%edx
  8009d4:	c1 fa 1f             	sar    $0x1f,%edx
  8009d7:	89 55 dc             	mov    %edx,-0x24(%ebp)
				putch(' ', putdat);
			break;

		// (signed) decimal
		case 'd':
			num = getint(&ap, lflag);
  8009da:	8b 4d d8             	mov    -0x28(%ebp),%ecx
  8009dd:	8b 5d dc             	mov    -0x24(%ebp),%ebx
  8009e0:	b8 0a 00 00 00       	mov    $0xa,%eax
			if ((long long) num < 0) {
  8009e5:	83 7d dc 00          	cmpl   $0x0,-0x24(%ebp)
  8009e9:	0f 89 9b 00 00 00    	jns    800a8a <vprintfmt+0x3bd>
				putch('-', putdat);
  8009ef:	89 74 24 04          	mov    %esi,0x4(%esp)
  8009f3:	c7 04 24 2d 00 00 00 	movl   $0x2d,(%esp)
  8009fa:	ff d7                	call   *%edi
				num = -(long long) num;
  8009fc:	8b 4d d8             	mov    -0x28(%ebp),%ecx
  8009ff:	8b 5d dc             	mov    -0x24(%ebp),%ebx
  800a02:	f7 d9                	neg    %ecx
  800a04:	83 d3 00             	adc    $0x0,%ebx
  800a07:	f7 db                	neg    %ebx
  800a09:	b8 0a 00 00 00       	mov    $0xa,%eax
  800a0e:	eb 7a                	jmp    800a8a <vprintfmt+0x3bd>
  800a10:	89 45 cc             	mov    %eax,-0x34(%ebp)
			base = 10;
			goto number;

		// unsigned decimal
		case 'u':
			num = getuint(&ap, lflag);
  800a13:	89 ca                	mov    %ecx,%edx
  800a15:	8d 45 14             	lea    0x14(%ebp),%eax
  800a18:	e8 59 fc ff ff       	call   800676 <getuint>
  800a1d:	89 c1                	mov    %eax,%ecx
  800a1f:	89 d3                	mov    %edx,%ebx
  800a21:	b8 0a 00 00 00       	mov    $0xa,%eax
			base = 10;
			goto number;
  800a26:	eb 62                	jmp    800a8a <vprintfmt+0x3bd>
  800a28:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// (unsigned) octal
		case 'o':
			num = getuint(&ap, lflag);
  800a2b:	89 ca                	mov    %ecx,%edx
  800a2d:	8d 45 14             	lea    0x14(%ebp),%eax
  800a30:	e8 41 fc ff ff       	call   800676 <getuint>
  800a35:	89 c1                	mov    %eax,%ecx
  800a37:	89 d3                	mov    %edx,%ebx
  800a39:	b8 08 00 00 00       	mov    $0x8,%eax
			base = 8;
			goto number;
  800a3e:	eb 4a                	jmp    800a8a <vprintfmt+0x3bd>
  800a40:	89 45 cc             	mov    %eax,-0x34(%ebp)
			break;
			**/

		// pointer
		case 'p':
			putch('0', putdat);
  800a43:	89 74 24 04          	mov    %esi,0x4(%esp)
  800a47:	c7 04 24 30 00 00 00 	movl   $0x30,(%esp)
  800a4e:	ff d7                	call   *%edi
			putch('x', putdat);
  800a50:	89 74 24 04          	mov    %esi,0x4(%esp)
  800a54:	c7 04 24 78 00 00 00 	movl   $0x78,(%esp)
  800a5b:	ff d7                	call   *%edi
			num = (unsigned long long)
  800a5d:	8b 45 14             	mov    0x14(%ebp),%eax
  800a60:	8d 50 04             	lea    0x4(%eax),%edx
  800a63:	89 55 14             	mov    %edx,0x14(%ebp)
  800a66:	8b 08                	mov    (%eax),%ecx
  800a68:	bb 00 00 00 00       	mov    $0x0,%ebx
  800a6d:	b8 10 00 00 00       	mov    $0x10,%eax
				(uintptr_t) va_arg(ap, void *);
			base = 16;
			goto number;
  800a72:	eb 16                	jmp    800a8a <vprintfmt+0x3bd>
  800a74:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// (unsigned) hexadecimal
		case 'x':
			num = getuint(&ap, lflag);
  800a77:	89 ca                	mov    %ecx,%edx
  800a79:	8d 45 14             	lea    0x14(%ebp),%eax
  800a7c:	e8 f5 fb ff ff       	call   800676 <getuint>
  800a81:	89 c1                	mov    %eax,%ecx
  800a83:	89 d3                	mov    %edx,%ebx
  800a85:	b8 10 00 00 00       	mov    $0x10,%eax
			base = 16;
		number:
			printnum(putch, putdat, num, base, width, padc);
  800a8a:	0f be 55 d4          	movsbl -0x2c(%ebp),%edx
  800a8e:	89 54 24 10          	mov    %edx,0x10(%esp)
  800a92:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  800a95:	89 54 24 0c          	mov    %edx,0xc(%esp)
  800a99:	89 44 24 08          	mov    %eax,0x8(%esp)
  800a9d:	89 0c 24             	mov    %ecx,(%esp)
  800aa0:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  800aa4:	89 f2                	mov    %esi,%edx
  800aa6:	89 f8                	mov    %edi,%eax
  800aa8:	e8 d3 fa ff ff       	call   800580 <printnum>
  800aad:	8b 5d cc             	mov    -0x34(%ebp),%ebx
			break;
  800ab0:	e9 44 fc ff ff       	jmp    8006f9 <vprintfmt+0x2c>
  800ab5:	89 45 cc             	mov    %eax,-0x34(%ebp)
  800ab8:	8b 55 e0             	mov    -0x20(%ebp),%edx

		// escaped '%' character
		case '%':
			putch(ch, putdat);
  800abb:	89 74 24 04          	mov    %esi,0x4(%esp)
  800abf:	89 14 24             	mov    %edx,(%esp)
  800ac2:	ff d7                	call   *%edi
  800ac4:	8b 5d cc             	mov    -0x34(%ebp),%ebx
			break;
  800ac7:	e9 2d fc ff ff       	jmp    8006f9 <vprintfmt+0x2c>
			
		// unrecognized escape sequence - just print it literally
		default:
			putch('%', putdat);
  800acc:	89 74 24 04          	mov    %esi,0x4(%esp)
  800ad0:	c7 04 24 25 00 00 00 	movl   $0x25,(%esp)
  800ad7:	ff d7                	call   *%edi
			for (fmt--; fmt[-1] != '%'; fmt--)
  800ad9:	8d 43 ff             	lea    -0x1(%ebx),%eax
  800adc:	80 38 25             	cmpb   $0x25,(%eax)
  800adf:	0f 84 14 fc ff ff    	je     8006f9 <vprintfmt+0x2c>
  800ae5:	89 c3                	mov    %eax,%ebx
  800ae7:	eb f0                	jmp    800ad9 <vprintfmt+0x40c>
				/* do nothing */;
			break;
		}
	}
}
  800ae9:	83 c4 5c             	add    $0x5c,%esp
  800aec:	5b                   	pop    %ebx
  800aed:	5e                   	pop    %esi
  800aee:	5f                   	pop    %edi
  800aef:	5d                   	pop    %ebp
  800af0:	c3                   	ret    

00800af1 <vsnprintf>:
		*b->buf++ = ch;
}

int
vsnprintf(char *buf, int n, const char *fmt, va_list ap)
{
  800af1:	55                   	push   %ebp
  800af2:	89 e5                	mov    %esp,%ebp
  800af4:	83 ec 28             	sub    $0x28,%esp
  800af7:	8b 45 08             	mov    0x8(%ebp),%eax
  800afa:	8b 55 0c             	mov    0xc(%ebp),%edx
	struct sprintbuf b = {buf, buf+n-1, 0};

	if (buf == NULL || n < 1)
  800afd:	85 c0                	test   %eax,%eax
  800aff:	74 04                	je     800b05 <vsnprintf+0x14>
  800b01:	85 d2                	test   %edx,%edx
  800b03:	7f 07                	jg     800b0c <vsnprintf+0x1b>
  800b05:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
  800b0a:	eb 3b                	jmp    800b47 <vsnprintf+0x56>
}

int
vsnprintf(char *buf, int n, const char *fmt, va_list ap)
{
	struct sprintbuf b = {buf, buf+n-1, 0};
  800b0c:	89 45 ec             	mov    %eax,-0x14(%ebp)
  800b0f:	8d 44 10 ff          	lea    -0x1(%eax,%edx,1),%eax
  800b13:	89 45 f0             	mov    %eax,-0x10(%ebp)
  800b16:	c7 45 f4 00 00 00 00 	movl   $0x0,-0xc(%ebp)

	if (buf == NULL || n < 1)
		return -E_INVAL;

	// print the string to the buffer
	vprintfmt((void*)sprintputch, &b, fmt, ap);
  800b1d:	8b 45 14             	mov    0x14(%ebp),%eax
  800b20:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800b24:	8b 45 10             	mov    0x10(%ebp),%eax
  800b27:	89 44 24 08          	mov    %eax,0x8(%esp)
  800b2b:	8d 45 ec             	lea    -0x14(%ebp),%eax
  800b2e:	89 44 24 04          	mov    %eax,0x4(%esp)
  800b32:	c7 04 24 b0 06 80 00 	movl   $0x8006b0,(%esp)
  800b39:	e8 8f fb ff ff       	call   8006cd <vprintfmt>

	// null terminate the buffer
	*b.buf = '\0';
  800b3e:	8b 45 ec             	mov    -0x14(%ebp),%eax
  800b41:	c6 00 00             	movb   $0x0,(%eax)

	return b.cnt;
  800b44:	8b 45 f4             	mov    -0xc(%ebp),%eax
}
  800b47:	c9                   	leave  
  800b48:	c3                   	ret    

00800b49 <snprintf>:

int
snprintf(char *buf, int n, const char *fmt, ...)
{
  800b49:	55                   	push   %ebp
  800b4a:	89 e5                	mov    %esp,%ebp
  800b4c:	83 ec 18             	sub    $0x18,%esp

	return b.cnt;
}

int
snprintf(char *buf, int n, const char *fmt, ...)
  800b4f:	8d 45 14             	lea    0x14(%ebp),%eax
{
	va_list ap;
	int rc;

	va_start(ap, fmt);
	rc = vsnprintf(buf, n, fmt, ap);
  800b52:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800b56:	8b 45 10             	mov    0x10(%ebp),%eax
  800b59:	89 44 24 08          	mov    %eax,0x8(%esp)
  800b5d:	8b 45 0c             	mov    0xc(%ebp),%eax
  800b60:	89 44 24 04          	mov    %eax,0x4(%esp)
  800b64:	8b 45 08             	mov    0x8(%ebp),%eax
  800b67:	89 04 24             	mov    %eax,(%esp)
  800b6a:	e8 82 ff ff ff       	call   800af1 <vsnprintf>
	va_end(ap);

	return rc;
}
  800b6f:	c9                   	leave  
  800b70:	c3                   	ret    

00800b71 <printfmt>:
	}
}

void
printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...)
{
  800b71:	55                   	push   %ebp
  800b72:	89 e5                	mov    %esp,%ebp
  800b74:	83 ec 18             	sub    $0x18,%esp
		}
	}
}

void
printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...)
  800b77:	8d 45 14             	lea    0x14(%ebp),%eax
{
	va_list ap;

	va_start(ap, fmt);
	vprintfmt(putch, putdat, fmt, ap);
  800b7a:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800b7e:	8b 45 10             	mov    0x10(%ebp),%eax
  800b81:	89 44 24 08          	mov    %eax,0x8(%esp)
  800b85:	8b 45 0c             	mov    0xc(%ebp),%eax
  800b88:	89 44 24 04          	mov    %eax,0x4(%esp)
  800b8c:	8b 45 08             	mov    0x8(%ebp),%eax
  800b8f:	89 04 24             	mov    %eax,(%esp)
  800b92:	e8 36 fb ff ff       	call   8006cd <vprintfmt>
	va_end(ap);
}
  800b97:	c9                   	leave  
  800b98:	c3                   	ret    
  800b99:	00 00                	add    %al,(%eax)
  800b9b:	00 00                	add    %al,(%eax)
  800b9d:	00 00                	add    %al,(%eax)
	...

00800ba0 <strlen>:
// Primespipe runs 3x faster this way.
#define ASM 1

int
strlen(const char *s)
{
  800ba0:	55                   	push   %ebp
  800ba1:	89 e5                	mov    %esp,%ebp
  800ba3:	8b 55 08             	mov    0x8(%ebp),%edx
	int n;

	for (n = 0; *s != '\0'; s++)
  800ba6:	b8 00 00 00 00       	mov    $0x0,%eax
  800bab:	80 3a 00             	cmpb   $0x0,(%edx)
  800bae:	74 09                	je     800bb9 <strlen+0x19>
		n++;
  800bb0:	83 c0 01             	add    $0x1,%eax
int
strlen(const char *s)
{
	int n;

	for (n = 0; *s != '\0'; s++)
  800bb3:	80 3c 02 00          	cmpb   $0x0,(%edx,%eax,1)
  800bb7:	75 f7                	jne    800bb0 <strlen+0x10>
		n++;
	return n;
}
  800bb9:	5d                   	pop    %ebp
  800bba:	c3                   	ret    

00800bbb <strnlen>:

int
strnlen(const char *s, size_t size)
{
  800bbb:	55                   	push   %ebp
  800bbc:	89 e5                	mov    %esp,%ebp
  800bbe:	53                   	push   %ebx
  800bbf:	8b 5d 08             	mov    0x8(%ebp),%ebx
  800bc2:	8b 4d 0c             	mov    0xc(%ebp),%ecx
	int n;

	for (n = 0; size > 0 && *s != '\0'; s++, size--)
  800bc5:	85 c9                	test   %ecx,%ecx
  800bc7:	74 19                	je     800be2 <strnlen+0x27>
  800bc9:	80 3b 00             	cmpb   $0x0,(%ebx)
  800bcc:	74 14                	je     800be2 <strnlen+0x27>
  800bce:	b8 00 00 00 00       	mov    $0x0,%eax
		n++;
  800bd3:	83 c0 01             	add    $0x1,%eax
int
strnlen(const char *s, size_t size)
{
	int n;

	for (n = 0; size > 0 && *s != '\0'; s++, size--)
  800bd6:	39 c8                	cmp    %ecx,%eax
  800bd8:	74 0d                	je     800be7 <strnlen+0x2c>
  800bda:	80 3c 03 00          	cmpb   $0x0,(%ebx,%eax,1)
  800bde:	75 f3                	jne    800bd3 <strnlen+0x18>
  800be0:	eb 05                	jmp    800be7 <strnlen+0x2c>
  800be2:	b8 00 00 00 00       	mov    $0x0,%eax
		n++;
	return n;
}
  800be7:	5b                   	pop    %ebx
  800be8:	5d                   	pop    %ebp
  800be9:	c3                   	ret    

00800bea <strcpy>:

char *
strcpy(char *dst, const char *src)
{
  800bea:	55                   	push   %ebp
  800beb:	89 e5                	mov    %esp,%ebp
  800bed:	53                   	push   %ebx
  800bee:	8b 45 08             	mov    0x8(%ebp),%eax
  800bf1:	8b 5d 0c             	mov    0xc(%ebp),%ebx
  800bf4:	ba 00 00 00 00       	mov    $0x0,%edx
	char *ret;

	ret = dst;
	while ((*dst++ = *src++) != '\0')
  800bf9:	0f b6 0c 13          	movzbl (%ebx,%edx,1),%ecx
  800bfd:	88 0c 10             	mov    %cl,(%eax,%edx,1)
  800c00:	83 c2 01             	add    $0x1,%edx
  800c03:	84 c9                	test   %cl,%cl
  800c05:	75 f2                	jne    800bf9 <strcpy+0xf>
		/* do nothing */;
	return ret;
}
  800c07:	5b                   	pop    %ebx
  800c08:	5d                   	pop    %ebp
  800c09:	c3                   	ret    

00800c0a <strncpy>:

char *
strncpy(char *dst, const char *src, size_t size) {
  800c0a:	55                   	push   %ebp
  800c0b:	89 e5                	mov    %esp,%ebp
  800c0d:	56                   	push   %esi
  800c0e:	53                   	push   %ebx
  800c0f:	8b 45 08             	mov    0x8(%ebp),%eax
  800c12:	8b 55 0c             	mov    0xc(%ebp),%edx
  800c15:	8b 75 10             	mov    0x10(%ebp),%esi
	size_t i;
	char *ret;

	ret = dst;
	for (i = 0; i < size; i++) {
  800c18:	85 f6                	test   %esi,%esi
  800c1a:	74 18                	je     800c34 <strncpy+0x2a>
  800c1c:	b9 00 00 00 00       	mov    $0x0,%ecx
		*dst++ = *src;
  800c21:	0f b6 1a             	movzbl (%edx),%ebx
  800c24:	88 1c 08             	mov    %bl,(%eax,%ecx,1)
		// If strlen(src) < size, null-pad 'dst' out to 'size' chars
		if (*src != '\0')
			src++;
  800c27:	80 3a 01             	cmpb   $0x1,(%edx)
  800c2a:	83 da ff             	sbb    $0xffffffff,%edx
strncpy(char *dst, const char *src, size_t size) {
	size_t i;
	char *ret;

	ret = dst;
	for (i = 0; i < size; i++) {
  800c2d:	83 c1 01             	add    $0x1,%ecx
  800c30:	39 ce                	cmp    %ecx,%esi
  800c32:	77 ed                	ja     800c21 <strncpy+0x17>
		// If strlen(src) < size, null-pad 'dst' out to 'size' chars
		if (*src != '\0')
			src++;
	}
	return ret;
}
  800c34:	5b                   	pop    %ebx
  800c35:	5e                   	pop    %esi
  800c36:	5d                   	pop    %ebp
  800c37:	c3                   	ret    

00800c38 <strlcpy>:

size_t
strlcpy(char *dst, const char *src, size_t size)
{
  800c38:	55                   	push   %ebp
  800c39:	89 e5                	mov    %esp,%ebp
  800c3b:	56                   	push   %esi
  800c3c:	53                   	push   %ebx
  800c3d:	8b 75 08             	mov    0x8(%ebp),%esi
  800c40:	8b 55 0c             	mov    0xc(%ebp),%edx
  800c43:	8b 4d 10             	mov    0x10(%ebp),%ecx
	char *dst_in;

	dst_in = dst;
	if (size > 0) {
  800c46:	89 f0                	mov    %esi,%eax
  800c48:	85 c9                	test   %ecx,%ecx
  800c4a:	74 27                	je     800c73 <strlcpy+0x3b>
		while (--size > 0 && *src != '\0')
  800c4c:	83 e9 01             	sub    $0x1,%ecx
  800c4f:	74 1d                	je     800c6e <strlcpy+0x36>
  800c51:	0f b6 1a             	movzbl (%edx),%ebx
  800c54:	84 db                	test   %bl,%bl
  800c56:	74 16                	je     800c6e <strlcpy+0x36>
			*dst++ = *src++;
  800c58:	88 18                	mov    %bl,(%eax)
  800c5a:	83 c0 01             	add    $0x1,%eax
{
	char *dst_in;

	dst_in = dst;
	if (size > 0) {
		while (--size > 0 && *src != '\0')
  800c5d:	83 e9 01             	sub    $0x1,%ecx
  800c60:	74 0e                	je     800c70 <strlcpy+0x38>
			*dst++ = *src++;
  800c62:	83 c2 01             	add    $0x1,%edx
{
	char *dst_in;

	dst_in = dst;
	if (size > 0) {
		while (--size > 0 && *src != '\0')
  800c65:	0f b6 1a             	movzbl (%edx),%ebx
  800c68:	84 db                	test   %bl,%bl
  800c6a:	75 ec                	jne    800c58 <strlcpy+0x20>
  800c6c:	eb 02                	jmp    800c70 <strlcpy+0x38>
  800c6e:	89 f0                	mov    %esi,%eax
			*dst++ = *src++;
		*dst = '\0';
  800c70:	c6 00 00             	movb   $0x0,(%eax)
  800c73:	29 f0                	sub    %esi,%eax
	}
	return dst - dst_in;
}
  800c75:	5b                   	pop    %ebx
  800c76:	5e                   	pop    %esi
  800c77:	5d                   	pop    %ebp
  800c78:	c3                   	ret    

00800c79 <strcmp>:

int
strcmp(const char *p, const char *q)
{
  800c79:	55                   	push   %ebp
  800c7a:	89 e5                	mov    %esp,%ebp
  800c7c:	8b 4d 08             	mov    0x8(%ebp),%ecx
  800c7f:	8b 55 0c             	mov    0xc(%ebp),%edx
	while (*p && *p == *q)
  800c82:	0f b6 01             	movzbl (%ecx),%eax
  800c85:	84 c0                	test   %al,%al
  800c87:	74 15                	je     800c9e <strcmp+0x25>
  800c89:	3a 02                	cmp    (%edx),%al
  800c8b:	75 11                	jne    800c9e <strcmp+0x25>
		p++, q++;
  800c8d:	83 c1 01             	add    $0x1,%ecx
  800c90:	83 c2 01             	add    $0x1,%edx
}

int
strcmp(const char *p, const char *q)
{
	while (*p && *p == *q)
  800c93:	0f b6 01             	movzbl (%ecx),%eax
  800c96:	84 c0                	test   %al,%al
  800c98:	74 04                	je     800c9e <strcmp+0x25>
  800c9a:	3a 02                	cmp    (%edx),%al
  800c9c:	74 ef                	je     800c8d <strcmp+0x14>
  800c9e:	0f b6 c0             	movzbl %al,%eax
  800ca1:	0f b6 12             	movzbl (%edx),%edx
  800ca4:	29 d0                	sub    %edx,%eax
		p++, q++;
	return (int) ((unsigned char) *p - (unsigned char) *q);
}
  800ca6:	5d                   	pop    %ebp
  800ca7:	c3                   	ret    

00800ca8 <strncmp>:

int
strncmp(const char *p, const char *q, size_t n)
{
  800ca8:	55                   	push   %ebp
  800ca9:	89 e5                	mov    %esp,%ebp
  800cab:	53                   	push   %ebx
  800cac:	8b 55 08             	mov    0x8(%ebp),%edx
  800caf:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800cb2:	8b 45 10             	mov    0x10(%ebp),%eax
	while (n > 0 && *p && *p == *q)
  800cb5:	85 c0                	test   %eax,%eax
  800cb7:	74 23                	je     800cdc <strncmp+0x34>
  800cb9:	0f b6 1a             	movzbl (%edx),%ebx
  800cbc:	84 db                	test   %bl,%bl
  800cbe:	74 24                	je     800ce4 <strncmp+0x3c>
  800cc0:	3a 19                	cmp    (%ecx),%bl
  800cc2:	75 20                	jne    800ce4 <strncmp+0x3c>
  800cc4:	83 e8 01             	sub    $0x1,%eax
  800cc7:	74 13                	je     800cdc <strncmp+0x34>
		n--, p++, q++;
  800cc9:	83 c2 01             	add    $0x1,%edx
  800ccc:	83 c1 01             	add    $0x1,%ecx
}

int
strncmp(const char *p, const char *q, size_t n)
{
	while (n > 0 && *p && *p == *q)
  800ccf:	0f b6 1a             	movzbl (%edx),%ebx
  800cd2:	84 db                	test   %bl,%bl
  800cd4:	74 0e                	je     800ce4 <strncmp+0x3c>
  800cd6:	3a 19                	cmp    (%ecx),%bl
  800cd8:	74 ea                	je     800cc4 <strncmp+0x1c>
  800cda:	eb 08                	jmp    800ce4 <strncmp+0x3c>
  800cdc:	b8 00 00 00 00       	mov    $0x0,%eax
		n--, p++, q++;
	if (n == 0)
		return 0;
	else
		return (int) ((unsigned char) *p - (unsigned char) *q);
}
  800ce1:	5b                   	pop    %ebx
  800ce2:	5d                   	pop    %ebp
  800ce3:	c3                   	ret    
	while (n > 0 && *p && *p == *q)
		n--, p++, q++;
	if (n == 0)
		return 0;
	else
		return (int) ((unsigned char) *p - (unsigned char) *q);
  800ce4:	0f b6 02             	movzbl (%edx),%eax
  800ce7:	0f b6 11             	movzbl (%ecx),%edx
  800cea:	29 d0                	sub    %edx,%eax
  800cec:	eb f3                	jmp    800ce1 <strncmp+0x39>

00800cee <strchr>:

// Return a pointer to the first occurrence of 'c' in 's',
// or a null pointer if the string has no 'c'.
char *
strchr(const char *s, char c)
{
  800cee:	55                   	push   %ebp
  800cef:	89 e5                	mov    %esp,%ebp
  800cf1:	8b 45 08             	mov    0x8(%ebp),%eax
  800cf4:	0f b6 4d 0c          	movzbl 0xc(%ebp),%ecx
	for (; *s; s++)
  800cf8:	0f b6 10             	movzbl (%eax),%edx
  800cfb:	84 d2                	test   %dl,%dl
  800cfd:	74 15                	je     800d14 <strchr+0x26>
		if (*s == c)
  800cff:	38 ca                	cmp    %cl,%dl
  800d01:	75 07                	jne    800d0a <strchr+0x1c>
  800d03:	eb 14                	jmp    800d19 <strchr+0x2b>
  800d05:	38 ca                	cmp    %cl,%dl
  800d07:	90                   	nop
  800d08:	74 0f                	je     800d19 <strchr+0x2b>
// Return a pointer to the first occurrence of 'c' in 's',
// or a null pointer if the string has no 'c'.
char *
strchr(const char *s, char c)
{
	for (; *s; s++)
  800d0a:	83 c0 01             	add    $0x1,%eax
  800d0d:	0f b6 10             	movzbl (%eax),%edx
  800d10:	84 d2                	test   %dl,%dl
  800d12:	75 f1                	jne    800d05 <strchr+0x17>
  800d14:	b8 00 00 00 00       	mov    $0x0,%eax
		if (*s == c)
			return (char *) s;
	return 0;
}
  800d19:	5d                   	pop    %ebp
  800d1a:	c3                   	ret    

00800d1b <strfind>:

// Return a pointer to the first occurrence of 'c' in 's',
// or a pointer to the string-ending null character if the string has no 'c'.
char *
strfind(const char *s, char c)
{
  800d1b:	55                   	push   %ebp
  800d1c:	89 e5                	mov    %esp,%ebp
  800d1e:	8b 45 08             	mov    0x8(%ebp),%eax
  800d21:	0f b6 4d 0c          	movzbl 0xc(%ebp),%ecx
	for (; *s; s++)
  800d25:	0f b6 10             	movzbl (%eax),%edx
  800d28:	84 d2                	test   %dl,%dl
  800d2a:	74 18                	je     800d44 <strfind+0x29>
		if (*s == c)
  800d2c:	38 ca                	cmp    %cl,%dl
  800d2e:	75 0a                	jne    800d3a <strfind+0x1f>
  800d30:	eb 12                	jmp    800d44 <strfind+0x29>
  800d32:	38 ca                	cmp    %cl,%dl
  800d34:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  800d38:	74 0a                	je     800d44 <strfind+0x29>
// Return a pointer to the first occurrence of 'c' in 's',
// or a pointer to the string-ending null character if the string has no 'c'.
char *
strfind(const char *s, char c)
{
	for (; *s; s++)
  800d3a:	83 c0 01             	add    $0x1,%eax
  800d3d:	0f b6 10             	movzbl (%eax),%edx
  800d40:	84 d2                	test   %dl,%dl
  800d42:	75 ee                	jne    800d32 <strfind+0x17>
		if (*s == c)
			break;
	return (char *) s;
}
  800d44:	5d                   	pop    %ebp
  800d45:	c3                   	ret    

00800d46 <memset>:

#if ASM
void *
memset(void *v, int c, size_t n)
{
  800d46:	55                   	push   %ebp
  800d47:	89 e5                	mov    %esp,%ebp
  800d49:	83 ec 0c             	sub    $0xc,%esp
  800d4c:	89 1c 24             	mov    %ebx,(%esp)
  800d4f:	89 74 24 04          	mov    %esi,0x4(%esp)
  800d53:	89 7c 24 08          	mov    %edi,0x8(%esp)
  800d57:	8b 7d 08             	mov    0x8(%ebp),%edi
  800d5a:	8b 45 0c             	mov    0xc(%ebp),%eax
  800d5d:	8b 4d 10             	mov    0x10(%ebp),%ecx
	char *p;

	if (n == 0)
  800d60:	85 c9                	test   %ecx,%ecx
  800d62:	74 30                	je     800d94 <memset+0x4e>
		return v;
	if ((int)v%4 == 0 && n%4 == 0) {
  800d64:	f7 c7 03 00 00 00    	test   $0x3,%edi
  800d6a:	75 25                	jne    800d91 <memset+0x4b>
  800d6c:	f6 c1 03             	test   $0x3,%cl
  800d6f:	75 20                	jne    800d91 <memset+0x4b>
		c &= 0xFF;
  800d71:	0f b6 d0             	movzbl %al,%edx
		c = (c<<24)|(c<<16)|(c<<8)|c;
  800d74:	89 d3                	mov    %edx,%ebx
  800d76:	c1 e3 08             	shl    $0x8,%ebx
  800d79:	89 d6                	mov    %edx,%esi
  800d7b:	c1 e6 18             	shl    $0x18,%esi
  800d7e:	89 d0                	mov    %edx,%eax
  800d80:	c1 e0 10             	shl    $0x10,%eax
  800d83:	09 f0                	or     %esi,%eax
  800d85:	09 d0                	or     %edx,%eax
		asm volatile("cld; rep stosl\n"
  800d87:	09 d8                	or     %ebx,%eax
  800d89:	c1 e9 02             	shr    $0x2,%ecx
  800d8c:	fc                   	cld    
  800d8d:	f3 ab                	rep stos %eax,%es:(%edi)
{
	char *p;

	if (n == 0)
		return v;
	if ((int)v%4 == 0 && n%4 == 0) {
  800d8f:	eb 03                	jmp    800d94 <memset+0x4e>
		c = (c<<24)|(c<<16)|(c<<8)|c;
		asm volatile("cld; rep stosl\n"
			:: "D" (v), "a" (c), "c" (n/4)
			: "cc", "memory");
	} else
		asm volatile("cld; rep stosb\n"
  800d91:	fc                   	cld    
  800d92:	f3 aa                	rep stos %al,%es:(%edi)
			:: "D" (v), "a" (c), "c" (n)
			: "cc", "memory");
	return v;
}
  800d94:	89 f8                	mov    %edi,%eax
  800d96:	8b 1c 24             	mov    (%esp),%ebx
  800d99:	8b 74 24 04          	mov    0x4(%esp),%esi
  800d9d:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800da1:	89 ec                	mov    %ebp,%esp
  800da3:	5d                   	pop    %ebp
  800da4:	c3                   	ret    

00800da5 <memmove>:

void *
memmove(void *dst, const void *src, size_t n)
{
  800da5:	55                   	push   %ebp
  800da6:	89 e5                	mov    %esp,%ebp
  800da8:	83 ec 08             	sub    $0x8,%esp
  800dab:	89 34 24             	mov    %esi,(%esp)
  800dae:	89 7c 24 04          	mov    %edi,0x4(%esp)
  800db2:	8b 45 08             	mov    0x8(%ebp),%eax
  800db5:	8b 4d 10             	mov    0x10(%ebp),%ecx
	const char *s;
	char *d;
	
	s = src;
  800db8:	8b 75 0c             	mov    0xc(%ebp),%esi
	d = dst;
  800dbb:	89 c7                	mov    %eax,%edi
	if (s < d && s + n > d) {
  800dbd:	39 c6                	cmp    %eax,%esi
  800dbf:	73 35                	jae    800df6 <memmove+0x51>
  800dc1:	8d 14 0e             	lea    (%esi,%ecx,1),%edx
  800dc4:	39 d0                	cmp    %edx,%eax
  800dc6:	73 2e                	jae    800df6 <memmove+0x51>
		s += n;
		d += n;
  800dc8:	01 cf                	add    %ecx,%edi
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  800dca:	f6 c2 03             	test   $0x3,%dl
  800dcd:	75 1b                	jne    800dea <memmove+0x45>
  800dcf:	f7 c7 03 00 00 00    	test   $0x3,%edi
  800dd5:	75 13                	jne    800dea <memmove+0x45>
  800dd7:	f6 c1 03             	test   $0x3,%cl
  800dda:	75 0e                	jne    800dea <memmove+0x45>
			asm volatile("std; rep movsl\n"
  800ddc:	83 ef 04             	sub    $0x4,%edi
  800ddf:	8d 72 fc             	lea    -0x4(%edx),%esi
  800de2:	c1 e9 02             	shr    $0x2,%ecx
  800de5:	fd                   	std    
  800de6:	f3 a5                	rep movsl %ds:(%esi),%es:(%edi)
	s = src;
	d = dst;
	if (s < d && s + n > d) {
		s += n;
		d += n;
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  800de8:	eb 09                	jmp    800df3 <memmove+0x4e>
			asm volatile("std; rep movsl\n"
				:: "D" (d-4), "S" (s-4), "c" (n/4) : "cc", "memory");
		else
			asm volatile("std; rep movsb\n"
  800dea:	83 ef 01             	sub    $0x1,%edi
  800ded:	8d 72 ff             	lea    -0x1(%edx),%esi
  800df0:	fd                   	std    
  800df1:	f3 a4                	rep movsb %ds:(%esi),%es:(%edi)
				:: "D" (d-1), "S" (s-1), "c" (n) : "cc", "memory");
		// Some versions of GCC rely on DF being clear
		asm volatile("cld" ::: "cc");
  800df3:	fc                   	cld    
	const char *s;
	char *d;
	
	s = src;
	d = dst;
	if (s < d && s + n > d) {
  800df4:	eb 20                	jmp    800e16 <memmove+0x71>
			asm volatile("std; rep movsb\n"
				:: "D" (d-1), "S" (s-1), "c" (n) : "cc", "memory");
		// Some versions of GCC rely on DF being clear
		asm volatile("cld" ::: "cc");
	} else {
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  800df6:	f7 c6 03 00 00 00    	test   $0x3,%esi
  800dfc:	75 15                	jne    800e13 <memmove+0x6e>
  800dfe:	f7 c7 03 00 00 00    	test   $0x3,%edi
  800e04:	75 0d                	jne    800e13 <memmove+0x6e>
  800e06:	f6 c1 03             	test   $0x3,%cl
  800e09:	75 08                	jne    800e13 <memmove+0x6e>
			asm volatile("cld; rep movsl\n"
  800e0b:	c1 e9 02             	shr    $0x2,%ecx
  800e0e:	fc                   	cld    
  800e0f:	f3 a5                	rep movsl %ds:(%esi),%es:(%edi)
			asm volatile("std; rep movsb\n"
				:: "D" (d-1), "S" (s-1), "c" (n) : "cc", "memory");
		// Some versions of GCC rely on DF being clear
		asm volatile("cld" ::: "cc");
	} else {
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  800e11:	eb 03                	jmp    800e16 <memmove+0x71>
			asm volatile("cld; rep movsl\n"
				:: "D" (d), "S" (s), "c" (n/4) : "cc", "memory");
		else
			asm volatile("cld; rep movsb\n"
  800e13:	fc                   	cld    
  800e14:	f3 a4                	rep movsb %ds:(%esi),%es:(%edi)
				:: "D" (d), "S" (s), "c" (n) : "cc", "memory");
	}
	return dst;
}
  800e16:	8b 34 24             	mov    (%esp),%esi
  800e19:	8b 7c 24 04          	mov    0x4(%esp),%edi
  800e1d:	89 ec                	mov    %ebp,%esp
  800e1f:	5d                   	pop    %ebp
  800e20:	c3                   	ret    

00800e21 <memcpy>:

/* sigh - gcc emits references to this for structure assignments! */
/* it is *not* prototyped in inc/string.h - do not use directly. */
void *
memcpy(void *dst, void *src, size_t n)
{
  800e21:	55                   	push   %ebp
  800e22:	89 e5                	mov    %esp,%ebp
  800e24:	83 ec 0c             	sub    $0xc,%esp
	return memmove(dst, src, n);
  800e27:	8b 45 10             	mov    0x10(%ebp),%eax
  800e2a:	89 44 24 08          	mov    %eax,0x8(%esp)
  800e2e:	8b 45 0c             	mov    0xc(%ebp),%eax
  800e31:	89 44 24 04          	mov    %eax,0x4(%esp)
  800e35:	8b 45 08             	mov    0x8(%ebp),%eax
  800e38:	89 04 24             	mov    %eax,(%esp)
  800e3b:	e8 65 ff ff ff       	call   800da5 <memmove>
}
  800e40:	c9                   	leave  
  800e41:	c3                   	ret    

00800e42 <memcmp>:

int
memcmp(const void *v1, const void *v2, size_t n)
{
  800e42:	55                   	push   %ebp
  800e43:	89 e5                	mov    %esp,%ebp
  800e45:	57                   	push   %edi
  800e46:	56                   	push   %esi
  800e47:	53                   	push   %ebx
  800e48:	8b 75 08             	mov    0x8(%ebp),%esi
  800e4b:	8b 7d 0c             	mov    0xc(%ebp),%edi
  800e4e:	8b 4d 10             	mov    0x10(%ebp),%ecx
	const uint8_t *s1 = (const uint8_t *) v1;
	const uint8_t *s2 = (const uint8_t *) v2;

	while (n-- > 0) {
  800e51:	85 c9                	test   %ecx,%ecx
  800e53:	74 36                	je     800e8b <memcmp+0x49>
		if (*s1 != *s2)
  800e55:	0f b6 06             	movzbl (%esi),%eax
  800e58:	0f b6 1f             	movzbl (%edi),%ebx
  800e5b:	38 d8                	cmp    %bl,%al
  800e5d:	74 20                	je     800e7f <memcmp+0x3d>
  800e5f:	eb 14                	jmp    800e75 <memcmp+0x33>
  800e61:	0f b6 44 16 01       	movzbl 0x1(%esi,%edx,1),%eax
  800e66:	0f b6 5c 17 01       	movzbl 0x1(%edi,%edx,1),%ebx
  800e6b:	83 c2 01             	add    $0x1,%edx
  800e6e:	83 e9 01             	sub    $0x1,%ecx
  800e71:	38 d8                	cmp    %bl,%al
  800e73:	74 12                	je     800e87 <memcmp+0x45>
			return (int) *s1 - (int) *s2;
  800e75:	0f b6 c0             	movzbl %al,%eax
  800e78:	0f b6 db             	movzbl %bl,%ebx
  800e7b:	29 d8                	sub    %ebx,%eax
  800e7d:	eb 11                	jmp    800e90 <memcmp+0x4e>
memcmp(const void *v1, const void *v2, size_t n)
{
	const uint8_t *s1 = (const uint8_t *) v1;
	const uint8_t *s2 = (const uint8_t *) v2;

	while (n-- > 0) {
  800e7f:	83 e9 01             	sub    $0x1,%ecx
  800e82:	ba 00 00 00 00       	mov    $0x0,%edx
  800e87:	85 c9                	test   %ecx,%ecx
  800e89:	75 d6                	jne    800e61 <memcmp+0x1f>
  800e8b:	b8 00 00 00 00       	mov    $0x0,%eax
			return (int) *s1 - (int) *s2;
		s1++, s2++;
	}

	return 0;
}
  800e90:	5b                   	pop    %ebx
  800e91:	5e                   	pop    %esi
  800e92:	5f                   	pop    %edi
  800e93:	5d                   	pop    %ebp
  800e94:	c3                   	ret    

00800e95 <memfind>:

void *
memfind(const void *s, int c, size_t n)
{
  800e95:	55                   	push   %ebp
  800e96:	89 e5                	mov    %esp,%ebp
  800e98:	8b 45 08             	mov    0x8(%ebp),%eax
	const void *ends = (const char *) s + n;
  800e9b:	89 c2                	mov    %eax,%edx
  800e9d:	03 55 10             	add    0x10(%ebp),%edx
	for (; s < ends; s++)
  800ea0:	39 d0                	cmp    %edx,%eax
  800ea2:	73 15                	jae    800eb9 <memfind+0x24>
		if (*(const unsigned char *) s == (unsigned char) c)
  800ea4:	0f b6 4d 0c          	movzbl 0xc(%ebp),%ecx
  800ea8:	38 08                	cmp    %cl,(%eax)
  800eaa:	75 06                	jne    800eb2 <memfind+0x1d>
  800eac:	eb 0b                	jmp    800eb9 <memfind+0x24>
  800eae:	38 08                	cmp    %cl,(%eax)
  800eb0:	74 07                	je     800eb9 <memfind+0x24>

void *
memfind(const void *s, int c, size_t n)
{
	const void *ends = (const char *) s + n;
	for (; s < ends; s++)
  800eb2:	83 c0 01             	add    $0x1,%eax
  800eb5:	39 c2                	cmp    %eax,%edx
  800eb7:	77 f5                	ja     800eae <memfind+0x19>
		if (*(const unsigned char *) s == (unsigned char) c)
			break;
	return (void *) s;
}
  800eb9:	5d                   	pop    %ebp
  800eba:	c3                   	ret    

00800ebb <strtol>:

long
strtol(const char *s, char **endptr, int base)
{
  800ebb:	55                   	push   %ebp
  800ebc:	89 e5                	mov    %esp,%ebp
  800ebe:	57                   	push   %edi
  800ebf:	56                   	push   %esi
  800ec0:	53                   	push   %ebx
  800ec1:	83 ec 04             	sub    $0x4,%esp
  800ec4:	8b 55 08             	mov    0x8(%ebp),%edx
  800ec7:	8b 5d 10             	mov    0x10(%ebp),%ebx
	int neg = 0;
	long val = 0;

	// gobble initial whitespace
	while (*s == ' ' || *s == '\t')
  800eca:	0f b6 02             	movzbl (%edx),%eax
  800ecd:	3c 20                	cmp    $0x20,%al
  800ecf:	74 04                	je     800ed5 <strtol+0x1a>
  800ed1:	3c 09                	cmp    $0x9,%al
  800ed3:	75 0e                	jne    800ee3 <strtol+0x28>
		s++;
  800ed5:	83 c2 01             	add    $0x1,%edx
{
	int neg = 0;
	long val = 0;

	// gobble initial whitespace
	while (*s == ' ' || *s == '\t')
  800ed8:	0f b6 02             	movzbl (%edx),%eax
  800edb:	3c 20                	cmp    $0x20,%al
  800edd:	74 f6                	je     800ed5 <strtol+0x1a>
  800edf:	3c 09                	cmp    $0x9,%al
  800ee1:	74 f2                	je     800ed5 <strtol+0x1a>
		s++;

	// plus/minus sign
	if (*s == '+')
  800ee3:	3c 2b                	cmp    $0x2b,%al
  800ee5:	75 0c                	jne    800ef3 <strtol+0x38>
		s++;
  800ee7:	83 c2 01             	add    $0x1,%edx
  800eea:	c7 45 f0 00 00 00 00 	movl   $0x0,-0x10(%ebp)
  800ef1:	eb 15                	jmp    800f08 <strtol+0x4d>
	else if (*s == '-')
  800ef3:	c7 45 f0 00 00 00 00 	movl   $0x0,-0x10(%ebp)
  800efa:	3c 2d                	cmp    $0x2d,%al
  800efc:	75 0a                	jne    800f08 <strtol+0x4d>
		s++, neg = 1;
  800efe:	83 c2 01             	add    $0x1,%edx
  800f01:	c7 45 f0 01 00 00 00 	movl   $0x1,-0x10(%ebp)

	// hex or octal base prefix
	if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
  800f08:	85 db                	test   %ebx,%ebx
  800f0a:	0f 94 c0             	sete   %al
  800f0d:	74 05                	je     800f14 <strtol+0x59>
  800f0f:	83 fb 10             	cmp    $0x10,%ebx
  800f12:	75 18                	jne    800f2c <strtol+0x71>
  800f14:	80 3a 30             	cmpb   $0x30,(%edx)
  800f17:	75 13                	jne    800f2c <strtol+0x71>
  800f19:	80 7a 01 78          	cmpb   $0x78,0x1(%edx)
  800f1d:	8d 76 00             	lea    0x0(%esi),%esi
  800f20:	75 0a                	jne    800f2c <strtol+0x71>
		s += 2, base = 16;
  800f22:	83 c2 02             	add    $0x2,%edx
  800f25:	bb 10 00 00 00       	mov    $0x10,%ebx
		s++;
	else if (*s == '-')
		s++, neg = 1;

	// hex or octal base prefix
	if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
  800f2a:	eb 15                	jmp    800f41 <strtol+0x86>
		s += 2, base = 16;
	else if (base == 0 && s[0] == '0')
  800f2c:	84 c0                	test   %al,%al
  800f2e:	66 90                	xchg   %ax,%ax
  800f30:	74 0f                	je     800f41 <strtol+0x86>
  800f32:	bb 0a 00 00 00       	mov    $0xa,%ebx
  800f37:	80 3a 30             	cmpb   $0x30,(%edx)
  800f3a:	75 05                	jne    800f41 <strtol+0x86>
		s++, base = 8;
  800f3c:	83 c2 01             	add    $0x1,%edx
  800f3f:	b3 08                	mov    $0x8,%bl
		s++, neg = 1;

	// hex or octal base prefix
	if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
		s += 2, base = 16;
	else if (base == 0 && s[0] == '0')
  800f41:	b8 00 00 00 00       	mov    $0x0,%eax
  800f46:	89 de                	mov    %ebx,%esi

	// digits
	while (1) {
		int dig;

		if (*s >= '0' && *s <= '9')
  800f48:	0f b6 0a             	movzbl (%edx),%ecx
  800f4b:	89 cf                	mov    %ecx,%edi
  800f4d:	8d 59 d0             	lea    -0x30(%ecx),%ebx
  800f50:	80 fb 09             	cmp    $0x9,%bl
  800f53:	77 08                	ja     800f5d <strtol+0xa2>
			dig = *s - '0';
  800f55:	0f be c9             	movsbl %cl,%ecx
  800f58:	83 e9 30             	sub    $0x30,%ecx
  800f5b:	eb 1e                	jmp    800f7b <strtol+0xc0>
		else if (*s >= 'a' && *s <= 'z')
  800f5d:	8d 5f 9f             	lea    -0x61(%edi),%ebx
  800f60:	80 fb 19             	cmp    $0x19,%bl
  800f63:	77 08                	ja     800f6d <strtol+0xb2>
			dig = *s - 'a' + 10;
  800f65:	0f be c9             	movsbl %cl,%ecx
  800f68:	83 e9 57             	sub    $0x57,%ecx
  800f6b:	eb 0e                	jmp    800f7b <strtol+0xc0>
		else if (*s >= 'A' && *s <= 'Z')
  800f6d:	8d 5f bf             	lea    -0x41(%edi),%ebx
  800f70:	80 fb 19             	cmp    $0x19,%bl
  800f73:	77 15                	ja     800f8a <strtol+0xcf>
			dig = *s - 'A' + 10;
  800f75:	0f be c9             	movsbl %cl,%ecx
  800f78:	83 e9 37             	sub    $0x37,%ecx
		else
			break;
		if (dig >= base)
  800f7b:	39 f1                	cmp    %esi,%ecx
  800f7d:	7d 0b                	jge    800f8a <strtol+0xcf>
			break;
		s++, val = (val * base) + dig;
  800f7f:	83 c2 01             	add    $0x1,%edx
  800f82:	0f af c6             	imul   %esi,%eax
  800f85:	8d 04 01             	lea    (%ecx,%eax,1),%eax
		// we don't properly detect overflow!
	}
  800f88:	eb be                	jmp    800f48 <strtol+0x8d>
  800f8a:	89 c1                	mov    %eax,%ecx

	if (endptr)
  800f8c:	83 7d 0c 00          	cmpl   $0x0,0xc(%ebp)
  800f90:	74 05                	je     800f97 <strtol+0xdc>
		*endptr = (char *) s;
  800f92:	8b 5d 0c             	mov    0xc(%ebp),%ebx
  800f95:	89 13                	mov    %edx,(%ebx)
	return (neg ? -val : val);
  800f97:	89 ca                	mov    %ecx,%edx
  800f99:	f7 da                	neg    %edx
  800f9b:	83 7d f0 00          	cmpl   $0x0,-0x10(%ebp)
  800f9f:	0f 45 c2             	cmovne %edx,%eax
}
  800fa2:	83 c4 04             	add    $0x4,%esp
  800fa5:	5b                   	pop    %ebx
  800fa6:	5e                   	pop    %esi
  800fa7:	5f                   	pop    %edi
  800fa8:	5d                   	pop    %ebp
  800fa9:	c3                   	ret    
	...

00800fac <sys_cgetc>:
	syscall(SYS_cputs, 0, (uint32_t)s, len, 0, 0, 0);
}

int
sys_cgetc(void)
{
  800fac:	55                   	push   %ebp
  800fad:	89 e5                	mov    %esp,%ebp
  800faf:	83 ec 0c             	sub    $0xc,%esp
  800fb2:	89 1c 24             	mov    %ebx,(%esp)
  800fb5:	89 74 24 04          	mov    %esi,0x4(%esp)
  800fb9:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800fbd:	ba 00 00 00 00       	mov    $0x0,%edx
  800fc2:	b8 01 00 00 00       	mov    $0x1,%eax
  800fc7:	89 d1                	mov    %edx,%ecx
  800fc9:	89 d3                	mov    %edx,%ebx
  800fcb:	89 d7                	mov    %edx,%edi
  800fcd:	89 d6                	mov    %edx,%esi
  800fcf:	cd 30                	int    $0x30

int
sys_cgetc(void)
{
	return syscall(SYS_cgetc, 0, 0, 0, 0, 0, 0);
}
  800fd1:	8b 1c 24             	mov    (%esp),%ebx
  800fd4:	8b 74 24 04          	mov    0x4(%esp),%esi
  800fd8:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800fdc:	89 ec                	mov    %ebp,%esp
  800fde:	5d                   	pop    %ebp
  800fdf:	c3                   	ret    

00800fe0 <sys_cputs>:
	return ret;
}

void
sys_cputs(const char *s, size_t len)
{
  800fe0:	55                   	push   %ebp
  800fe1:	89 e5                	mov    %esp,%ebp
  800fe3:	83 ec 0c             	sub    $0xc,%esp
  800fe6:	89 1c 24             	mov    %ebx,(%esp)
  800fe9:	89 74 24 04          	mov    %esi,0x4(%esp)
  800fed:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800ff1:	b8 00 00 00 00       	mov    $0x0,%eax
  800ff6:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800ff9:	8b 55 08             	mov    0x8(%ebp),%edx
  800ffc:	89 c3                	mov    %eax,%ebx
  800ffe:	89 c7                	mov    %eax,%edi
  801000:	89 c6                	mov    %eax,%esi
  801002:	cd 30                	int    $0x30

void
sys_cputs(const char *s, size_t len)
{
	syscall(SYS_cputs, 0, (uint32_t)s, len, 0, 0, 0);
}
  801004:	8b 1c 24             	mov    (%esp),%ebx
  801007:	8b 74 24 04          	mov    0x4(%esp),%esi
  80100b:	8b 7c 24 08          	mov    0x8(%esp),%edi
  80100f:	89 ec                	mov    %ebp,%esp
  801011:	5d                   	pop    %ebp
  801012:	c3                   	ret    

00801013 <sys_ns_recv>:
  return syscall(SYS_ns_send, 0, (uint32_t)pkt, len, 0, 0, 0);
}

int
sys_ns_recv(void *pkt, uint32_t len)
{
  801013:	55                   	push   %ebp
  801014:	89 e5                	mov    %esp,%ebp
  801016:	83 ec 0c             	sub    $0xc,%esp
  801019:	89 1c 24             	mov    %ebx,(%esp)
  80101c:	89 74 24 04          	mov    %esi,0x4(%esp)
  801020:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  801024:	bb 00 00 00 00       	mov    $0x0,%ebx
  801029:	b8 10 00 00 00       	mov    $0x10,%eax
  80102e:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  801031:	8b 55 08             	mov    0x8(%ebp),%edx
  801034:	89 df                	mov    %ebx,%edi
  801036:	89 de                	mov    %ebx,%esi
  801038:	cd 30                	int    $0x30

int
sys_ns_recv(void *pkt, uint32_t len)
{
  return syscall(SYS_ns_recv, 0, (uint32_t)pkt, len, 0, 0, 0);
}
  80103a:	8b 1c 24             	mov    (%esp),%ebx
  80103d:	8b 74 24 04          	mov    0x4(%esp),%esi
  801041:	8b 7c 24 08          	mov    0x8(%esp),%edi
  801045:	89 ec                	mov    %ebp,%esp
  801047:	5d                   	pop    %ebp
  801048:	c3                   	ret    

00801049 <sys_ns_send>:
	return (unsigned int) syscall(SYS_time_msec, 0, 0, 0, 0, 0, 0);
}

int
sys_ns_send(void *pkt, uint32_t len)
{
  801049:	55                   	push   %ebp
  80104a:	89 e5                	mov    %esp,%ebp
  80104c:	83 ec 0c             	sub    $0xc,%esp
  80104f:	89 1c 24             	mov    %ebx,(%esp)
  801052:	89 74 24 04          	mov    %esi,0x4(%esp)
  801056:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  80105a:	bb 00 00 00 00       	mov    $0x0,%ebx
  80105f:	b8 0f 00 00 00       	mov    $0xf,%eax
  801064:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  801067:	8b 55 08             	mov    0x8(%ebp),%edx
  80106a:	89 df                	mov    %ebx,%edi
  80106c:	89 de                	mov    %ebx,%esi
  80106e:	cd 30                	int    $0x30

int
sys_ns_send(void *pkt, uint32_t len)
{
  return syscall(SYS_ns_send, 0, (uint32_t)pkt, len, 0, 0, 0);
}
  801070:	8b 1c 24             	mov    (%esp),%ebx
  801073:	8b 74 24 04          	mov    0x4(%esp),%esi
  801077:	8b 7c 24 08          	mov    0x8(%esp),%edi
  80107b:	89 ec                	mov    %ebp,%esp
  80107d:	5d                   	pop    %ebp
  80107e:	c3                   	ret    

0080107f <sys_time_msec>:
	return syscall(SYS_ipc_recv, 1, (uint32_t)dstva, 0, 0, 0, 0);
}

unsigned int
sys_time_msec(void)
{
  80107f:	55                   	push   %ebp
  801080:	89 e5                	mov    %esp,%ebp
  801082:	83 ec 0c             	sub    $0xc,%esp
  801085:	89 1c 24             	mov    %ebx,(%esp)
  801088:	89 74 24 04          	mov    %esi,0x4(%esp)
  80108c:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  801090:	ba 00 00 00 00       	mov    $0x0,%edx
  801095:	b8 0e 00 00 00       	mov    $0xe,%eax
  80109a:	89 d1                	mov    %edx,%ecx
  80109c:	89 d3                	mov    %edx,%ebx
  80109e:	89 d7                	mov    %edx,%edi
  8010a0:	89 d6                	mov    %edx,%esi
  8010a2:	cd 30                	int    $0x30

unsigned int
sys_time_msec(void)
{
	return (unsigned int) syscall(SYS_time_msec, 0, 0, 0, 0, 0, 0);
}
  8010a4:	8b 1c 24             	mov    (%esp),%ebx
  8010a7:	8b 74 24 04          	mov    0x4(%esp),%esi
  8010ab:	8b 7c 24 08          	mov    0x8(%esp),%edi
  8010af:	89 ec                	mov    %ebp,%esp
  8010b1:	5d                   	pop    %ebp
  8010b2:	c3                   	ret    

008010b3 <sys_ipc_recv>:
	return syscall(SYS_ipc_try_send, 1, envid, value, (uint32_t) srcva, perm, 0);
}

int
sys_ipc_recv(void *dstva)
{
  8010b3:	55                   	push   %ebp
  8010b4:	89 e5                	mov    %esp,%ebp
  8010b6:	83 ec 38             	sub    $0x38,%esp
  8010b9:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  8010bc:	89 75 f8             	mov    %esi,-0x8(%ebp)
  8010bf:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  8010c2:	b9 00 00 00 00       	mov    $0x0,%ecx
  8010c7:	b8 0d 00 00 00       	mov    $0xd,%eax
  8010cc:	8b 55 08             	mov    0x8(%ebp),%edx
  8010cf:	89 cb                	mov    %ecx,%ebx
  8010d1:	89 cf                	mov    %ecx,%edi
  8010d3:	89 ce                	mov    %ecx,%esi
  8010d5:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  8010d7:	85 c0                	test   %eax,%eax
  8010d9:	7e 28                	jle    801103 <sys_ipc_recv+0x50>
		panic("syscall %d returned %d (> 0)", num, ret);
  8010db:	89 44 24 10          	mov    %eax,0x10(%esp)
  8010df:	c7 44 24 0c 0d 00 00 	movl   $0xd,0xc(%esp)
  8010e6:	00 
  8010e7:	c7 44 24 08 eb 34 80 	movl   $0x8034eb,0x8(%esp)
  8010ee:	00 
  8010ef:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  8010f6:	00 
  8010f7:	c7 04 24 08 35 80 00 	movl   $0x803508,(%esp)
  8010fe:	e8 4d f3 ff ff       	call   800450 <_panic>

int
sys_ipc_recv(void *dstva)
{
	return syscall(SYS_ipc_recv, 1, (uint32_t)dstva, 0, 0, 0, 0);
}
  801103:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  801106:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801109:	8b 7d fc             	mov    -0x4(%ebp),%edi
  80110c:	89 ec                	mov    %ebp,%esp
  80110e:	5d                   	pop    %ebp
  80110f:	c3                   	ret    

00801110 <sys_ipc_try_send>:
	return syscall(SYS_env_set_pgfault_upcall, 1, envid, (uint32_t) upcall, 0, 0, 0);
}

int
sys_ipc_try_send(envid_t envid, uint32_t value, void *srcva, int perm)
{
  801110:	55                   	push   %ebp
  801111:	89 e5                	mov    %esp,%ebp
  801113:	83 ec 38             	sub    $0x38,%esp
  801116:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  801119:	89 75 f8             	mov    %esi,-0x8(%ebp)
  80111c:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  80111f:	be 00 00 00 00       	mov    $0x0,%esi
  801124:	b8 0c 00 00 00       	mov    $0xc,%eax
  801129:	8b 7d 14             	mov    0x14(%ebp),%edi
  80112c:	8b 5d 10             	mov    0x10(%ebp),%ebx
  80112f:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  801132:	8b 55 08             	mov    0x8(%ebp),%edx
  801135:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  801137:	85 c0                	test   %eax,%eax
  801139:	7e 28                	jle    801163 <sys_ipc_try_send+0x53>
		panic("syscall %d returned %d (> 0)", num, ret);
  80113b:	89 44 24 10          	mov    %eax,0x10(%esp)
  80113f:	c7 44 24 0c 0c 00 00 	movl   $0xc,0xc(%esp)
  801146:	00 
  801147:	c7 44 24 08 eb 34 80 	movl   $0x8034eb,0x8(%esp)
  80114e:	00 
  80114f:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  801156:	00 
  801157:	c7 04 24 08 35 80 00 	movl   $0x803508,(%esp)
  80115e:	e8 ed f2 ff ff       	call   800450 <_panic>

int
sys_ipc_try_send(envid_t envid, uint32_t value, void *srcva, int perm)
{
	return syscall(SYS_ipc_try_send, 1, envid, value, (uint32_t) srcva, perm, 0);
}
  801163:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  801166:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801169:	8b 7d fc             	mov    -0x4(%ebp),%edi
  80116c:	89 ec                	mov    %ebp,%esp
  80116e:	5d                   	pop    %ebp
  80116f:	c3                   	ret    

00801170 <sys_env_set_pgfault_upcall>:
	return syscall(SYS_env_set_trapframe, 1, envid, (uint32_t) tf, 0, 0, 0);
}

int
sys_env_set_pgfault_upcall(envid_t envid, void *upcall)
{
  801170:	55                   	push   %ebp
  801171:	89 e5                	mov    %esp,%ebp
  801173:	83 ec 38             	sub    $0x38,%esp
  801176:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  801179:	89 75 f8             	mov    %esi,-0x8(%ebp)
  80117c:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  80117f:	bb 00 00 00 00       	mov    $0x0,%ebx
  801184:	b8 0a 00 00 00       	mov    $0xa,%eax
  801189:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  80118c:	8b 55 08             	mov    0x8(%ebp),%edx
  80118f:	89 df                	mov    %ebx,%edi
  801191:	89 de                	mov    %ebx,%esi
  801193:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  801195:	85 c0                	test   %eax,%eax
  801197:	7e 28                	jle    8011c1 <sys_env_set_pgfault_upcall+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  801199:	89 44 24 10          	mov    %eax,0x10(%esp)
  80119d:	c7 44 24 0c 0a 00 00 	movl   $0xa,0xc(%esp)
  8011a4:	00 
  8011a5:	c7 44 24 08 eb 34 80 	movl   $0x8034eb,0x8(%esp)
  8011ac:	00 
  8011ad:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  8011b4:	00 
  8011b5:	c7 04 24 08 35 80 00 	movl   $0x803508,(%esp)
  8011bc:	e8 8f f2 ff ff       	call   800450 <_panic>

int
sys_env_set_pgfault_upcall(envid_t envid, void *upcall)
{
	return syscall(SYS_env_set_pgfault_upcall, 1, envid, (uint32_t) upcall, 0, 0, 0);
}
  8011c1:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  8011c4:	8b 75 f8             	mov    -0x8(%ebp),%esi
  8011c7:	8b 7d fc             	mov    -0x4(%ebp),%edi
  8011ca:	89 ec                	mov    %ebp,%esp
  8011cc:	5d                   	pop    %ebp
  8011cd:	c3                   	ret    

008011ce <sys_env_set_trapframe>:
	return syscall(SYS_env_set_status, 1, envid, status, 0, 0, 0);
}

int
sys_env_set_trapframe(envid_t envid, struct Trapframe *tf)
{
  8011ce:	55                   	push   %ebp
  8011cf:	89 e5                	mov    %esp,%ebp
  8011d1:	83 ec 38             	sub    $0x38,%esp
  8011d4:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  8011d7:	89 75 f8             	mov    %esi,-0x8(%ebp)
  8011da:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  8011dd:	bb 00 00 00 00       	mov    $0x0,%ebx
  8011e2:	b8 09 00 00 00       	mov    $0x9,%eax
  8011e7:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  8011ea:	8b 55 08             	mov    0x8(%ebp),%edx
  8011ed:	89 df                	mov    %ebx,%edi
  8011ef:	89 de                	mov    %ebx,%esi
  8011f1:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  8011f3:	85 c0                	test   %eax,%eax
  8011f5:	7e 28                	jle    80121f <sys_env_set_trapframe+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  8011f7:	89 44 24 10          	mov    %eax,0x10(%esp)
  8011fb:	c7 44 24 0c 09 00 00 	movl   $0x9,0xc(%esp)
  801202:	00 
  801203:	c7 44 24 08 eb 34 80 	movl   $0x8034eb,0x8(%esp)
  80120a:	00 
  80120b:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  801212:	00 
  801213:	c7 04 24 08 35 80 00 	movl   $0x803508,(%esp)
  80121a:	e8 31 f2 ff ff       	call   800450 <_panic>

int
sys_env_set_trapframe(envid_t envid, struct Trapframe *tf)
{
	return syscall(SYS_env_set_trapframe, 1, envid, (uint32_t) tf, 0, 0, 0);
}
  80121f:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  801222:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801225:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801228:	89 ec                	mov    %ebp,%esp
  80122a:	5d                   	pop    %ebp
  80122b:	c3                   	ret    

0080122c <sys_env_set_status>:

// sys_exofork is inlined in lib.h

int
sys_env_set_status(envid_t envid, int status)
{
  80122c:	55                   	push   %ebp
  80122d:	89 e5                	mov    %esp,%ebp
  80122f:	83 ec 38             	sub    $0x38,%esp
  801232:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  801235:	89 75 f8             	mov    %esi,-0x8(%ebp)
  801238:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  80123b:	bb 00 00 00 00       	mov    $0x0,%ebx
  801240:	b8 08 00 00 00       	mov    $0x8,%eax
  801245:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  801248:	8b 55 08             	mov    0x8(%ebp),%edx
  80124b:	89 df                	mov    %ebx,%edi
  80124d:	89 de                	mov    %ebx,%esi
  80124f:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  801251:	85 c0                	test   %eax,%eax
  801253:	7e 28                	jle    80127d <sys_env_set_status+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  801255:	89 44 24 10          	mov    %eax,0x10(%esp)
  801259:	c7 44 24 0c 08 00 00 	movl   $0x8,0xc(%esp)
  801260:	00 
  801261:	c7 44 24 08 eb 34 80 	movl   $0x8034eb,0x8(%esp)
  801268:	00 
  801269:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  801270:	00 
  801271:	c7 04 24 08 35 80 00 	movl   $0x803508,(%esp)
  801278:	e8 d3 f1 ff ff       	call   800450 <_panic>

int
sys_env_set_status(envid_t envid, int status)
{
	return syscall(SYS_env_set_status, 1, envid, status, 0, 0, 0);
}
  80127d:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  801280:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801283:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801286:	89 ec                	mov    %ebp,%esp
  801288:	5d                   	pop    %ebp
  801289:	c3                   	ret    

0080128a <sys_page_unmap>:
	return syscall(SYS_page_map, 1, srcenv, (uint32_t) srcva, dstenv, (uint32_t) dstva, perm);
}

int
sys_page_unmap(envid_t envid, void *va)
{
  80128a:	55                   	push   %ebp
  80128b:	89 e5                	mov    %esp,%ebp
  80128d:	83 ec 38             	sub    $0x38,%esp
  801290:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  801293:	89 75 f8             	mov    %esi,-0x8(%ebp)
  801296:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  801299:	bb 00 00 00 00       	mov    $0x0,%ebx
  80129e:	b8 06 00 00 00       	mov    $0x6,%eax
  8012a3:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  8012a6:	8b 55 08             	mov    0x8(%ebp),%edx
  8012a9:	89 df                	mov    %ebx,%edi
  8012ab:	89 de                	mov    %ebx,%esi
  8012ad:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  8012af:	85 c0                	test   %eax,%eax
  8012b1:	7e 28                	jle    8012db <sys_page_unmap+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  8012b3:	89 44 24 10          	mov    %eax,0x10(%esp)
  8012b7:	c7 44 24 0c 06 00 00 	movl   $0x6,0xc(%esp)
  8012be:	00 
  8012bf:	c7 44 24 08 eb 34 80 	movl   $0x8034eb,0x8(%esp)
  8012c6:	00 
  8012c7:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  8012ce:	00 
  8012cf:	c7 04 24 08 35 80 00 	movl   $0x803508,(%esp)
  8012d6:	e8 75 f1 ff ff       	call   800450 <_panic>

int
sys_page_unmap(envid_t envid, void *va)
{
	return syscall(SYS_page_unmap, 1, envid, (uint32_t) va, 0, 0, 0);
}
  8012db:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  8012de:	8b 75 f8             	mov    -0x8(%ebp),%esi
  8012e1:	8b 7d fc             	mov    -0x4(%ebp),%edi
  8012e4:	89 ec                	mov    %ebp,%esp
  8012e6:	5d                   	pop    %ebp
  8012e7:	c3                   	ret    

008012e8 <sys_page_map>:
	return syscall(SYS_page_alloc, 1, envid, (uint32_t) va, perm, 0, 0);
}

int
sys_page_map(envid_t srcenv, void *srcva, envid_t dstenv, void *dstva, int perm)
{
  8012e8:	55                   	push   %ebp
  8012e9:	89 e5                	mov    %esp,%ebp
  8012eb:	83 ec 38             	sub    $0x38,%esp
  8012ee:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  8012f1:	89 75 f8             	mov    %esi,-0x8(%ebp)
  8012f4:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  8012f7:	b8 05 00 00 00       	mov    $0x5,%eax
  8012fc:	8b 75 18             	mov    0x18(%ebp),%esi
  8012ff:	8b 7d 14             	mov    0x14(%ebp),%edi
  801302:	8b 5d 10             	mov    0x10(%ebp),%ebx
  801305:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  801308:	8b 55 08             	mov    0x8(%ebp),%edx
  80130b:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  80130d:	85 c0                	test   %eax,%eax
  80130f:	7e 28                	jle    801339 <sys_page_map+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  801311:	89 44 24 10          	mov    %eax,0x10(%esp)
  801315:	c7 44 24 0c 05 00 00 	movl   $0x5,0xc(%esp)
  80131c:	00 
  80131d:	c7 44 24 08 eb 34 80 	movl   $0x8034eb,0x8(%esp)
  801324:	00 
  801325:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  80132c:	00 
  80132d:	c7 04 24 08 35 80 00 	movl   $0x803508,(%esp)
  801334:	e8 17 f1 ff ff       	call   800450 <_panic>

int
sys_page_map(envid_t srcenv, void *srcva, envid_t dstenv, void *dstva, int perm)
{
	return syscall(SYS_page_map, 1, srcenv, (uint32_t) srcva, dstenv, (uint32_t) dstva, perm);
}
  801339:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  80133c:	8b 75 f8             	mov    -0x8(%ebp),%esi
  80133f:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801342:	89 ec                	mov    %ebp,%esp
  801344:	5d                   	pop    %ebp
  801345:	c3                   	ret    

00801346 <sys_page_alloc>:
	syscall(SYS_yield, 0, 0, 0, 0, 0, 0);
}

int
sys_page_alloc(envid_t envid, void *va, int perm)
{
  801346:	55                   	push   %ebp
  801347:	89 e5                	mov    %esp,%ebp
  801349:	83 ec 38             	sub    $0x38,%esp
  80134c:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  80134f:	89 75 f8             	mov    %esi,-0x8(%ebp)
  801352:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  801355:	be 00 00 00 00       	mov    $0x0,%esi
  80135a:	b8 04 00 00 00       	mov    $0x4,%eax
  80135f:	8b 5d 10             	mov    0x10(%ebp),%ebx
  801362:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  801365:	8b 55 08             	mov    0x8(%ebp),%edx
  801368:	89 f7                	mov    %esi,%edi
  80136a:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  80136c:	85 c0                	test   %eax,%eax
  80136e:	7e 28                	jle    801398 <sys_page_alloc+0x52>
		panic("syscall %d returned %d (> 0)", num, ret);
  801370:	89 44 24 10          	mov    %eax,0x10(%esp)
  801374:	c7 44 24 0c 04 00 00 	movl   $0x4,0xc(%esp)
  80137b:	00 
  80137c:	c7 44 24 08 eb 34 80 	movl   $0x8034eb,0x8(%esp)
  801383:	00 
  801384:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  80138b:	00 
  80138c:	c7 04 24 08 35 80 00 	movl   $0x803508,(%esp)
  801393:	e8 b8 f0 ff ff       	call   800450 <_panic>

int
sys_page_alloc(envid_t envid, void *va, int perm)
{
	return syscall(SYS_page_alloc, 1, envid, (uint32_t) va, perm, 0, 0);
}
  801398:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  80139b:	8b 75 f8             	mov    -0x8(%ebp),%esi
  80139e:	8b 7d fc             	mov    -0x4(%ebp),%edi
  8013a1:	89 ec                	mov    %ebp,%esp
  8013a3:	5d                   	pop    %ebp
  8013a4:	c3                   	ret    

008013a5 <sys_yield>:
	 return syscall(SYS_getenvid, 0, 0, 0, 0, 0, 0);
}

void
sys_yield(void)
{
  8013a5:	55                   	push   %ebp
  8013a6:	89 e5                	mov    %esp,%ebp
  8013a8:	83 ec 0c             	sub    $0xc,%esp
  8013ab:	89 1c 24             	mov    %ebx,(%esp)
  8013ae:	89 74 24 04          	mov    %esi,0x4(%esp)
  8013b2:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  8013b6:	ba 00 00 00 00       	mov    $0x0,%edx
  8013bb:	b8 0b 00 00 00       	mov    $0xb,%eax
  8013c0:	89 d1                	mov    %edx,%ecx
  8013c2:	89 d3                	mov    %edx,%ebx
  8013c4:	89 d7                	mov    %edx,%edi
  8013c6:	89 d6                	mov    %edx,%esi
  8013c8:	cd 30                	int    $0x30

void
sys_yield(void)
{
	syscall(SYS_yield, 0, 0, 0, 0, 0, 0);
}
  8013ca:	8b 1c 24             	mov    (%esp),%ebx
  8013cd:	8b 74 24 04          	mov    0x4(%esp),%esi
  8013d1:	8b 7c 24 08          	mov    0x8(%esp),%edi
  8013d5:	89 ec                	mov    %ebp,%esp
  8013d7:	5d                   	pop    %ebp
  8013d8:	c3                   	ret    

008013d9 <sys_getenvid>:
	return syscall(SYS_env_destroy, 1, envid, 0, 0, 0, 0);
}

envid_t
sys_getenvid(void)
{
  8013d9:	55                   	push   %ebp
  8013da:	89 e5                	mov    %esp,%ebp
  8013dc:	83 ec 0c             	sub    $0xc,%esp
  8013df:	89 1c 24             	mov    %ebx,(%esp)
  8013e2:	89 74 24 04          	mov    %esi,0x4(%esp)
  8013e6:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  8013ea:	ba 00 00 00 00       	mov    $0x0,%edx
  8013ef:	b8 02 00 00 00       	mov    $0x2,%eax
  8013f4:	89 d1                	mov    %edx,%ecx
  8013f6:	89 d3                	mov    %edx,%ebx
  8013f8:	89 d7                	mov    %edx,%edi
  8013fa:	89 d6                	mov    %edx,%esi
  8013fc:	cd 30                	int    $0x30

envid_t
sys_getenvid(void)
{
	 return syscall(SYS_getenvid, 0, 0, 0, 0, 0, 0);
}
  8013fe:	8b 1c 24             	mov    (%esp),%ebx
  801401:	8b 74 24 04          	mov    0x4(%esp),%esi
  801405:	8b 7c 24 08          	mov    0x8(%esp),%edi
  801409:	89 ec                	mov    %ebp,%esp
  80140b:	5d                   	pop    %ebp
  80140c:	c3                   	ret    

0080140d <sys_env_destroy>:
	return syscall(SYS_cgetc, 0, 0, 0, 0, 0, 0);
}

int
sys_env_destroy(envid_t envid)
{
  80140d:	55                   	push   %ebp
  80140e:	89 e5                	mov    %esp,%ebp
  801410:	83 ec 38             	sub    $0x38,%esp
  801413:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  801416:	89 75 f8             	mov    %esi,-0x8(%ebp)
  801419:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  80141c:	b9 00 00 00 00       	mov    $0x0,%ecx
  801421:	b8 03 00 00 00       	mov    $0x3,%eax
  801426:	8b 55 08             	mov    0x8(%ebp),%edx
  801429:	89 cb                	mov    %ecx,%ebx
  80142b:	89 cf                	mov    %ecx,%edi
  80142d:	89 ce                	mov    %ecx,%esi
  80142f:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  801431:	85 c0                	test   %eax,%eax
  801433:	7e 28                	jle    80145d <sys_env_destroy+0x50>
		panic("syscall %d returned %d (> 0)", num, ret);
  801435:	89 44 24 10          	mov    %eax,0x10(%esp)
  801439:	c7 44 24 0c 03 00 00 	movl   $0x3,0xc(%esp)
  801440:	00 
  801441:	c7 44 24 08 eb 34 80 	movl   $0x8034eb,0x8(%esp)
  801448:	00 
  801449:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  801450:	00 
  801451:	c7 04 24 08 35 80 00 	movl   $0x803508,(%esp)
  801458:	e8 f3 ef ff ff       	call   800450 <_panic>

int
sys_env_destroy(envid_t envid)
{
	return syscall(SYS_env_destroy, 1, envid, 0, 0, 0, 0);
}
  80145d:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  801460:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801463:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801466:	89 ec                	mov    %ebp,%esp
  801468:	5d                   	pop    %ebp
  801469:	c3                   	ret    
  80146a:	00 00                	add    %al,(%eax)
  80146c:	00 00                	add    %al,(%eax)
	...

00801470 <fd2num>:
// File descriptor manipulators
// --------------------------------------------------------------

int
fd2num(struct Fd *fd)
{
  801470:	55                   	push   %ebp
  801471:	89 e5                	mov    %esp,%ebp
  801473:	8b 45 08             	mov    0x8(%ebp),%eax
  801476:	05 00 00 00 30       	add    $0x30000000,%eax
  80147b:	c1 e8 0c             	shr    $0xc,%eax
	return ((uintptr_t) fd - FDTABLE) / PGSIZE;
}
  80147e:	5d                   	pop    %ebp
  80147f:	c3                   	ret    

00801480 <fd2data>:

char*
fd2data(struct Fd *fd)
{
  801480:	55                   	push   %ebp
  801481:	89 e5                	mov    %esp,%ebp
  801483:	83 ec 04             	sub    $0x4,%esp
	return INDEX2DATA(fd2num(fd));
  801486:	8b 45 08             	mov    0x8(%ebp),%eax
  801489:	89 04 24             	mov    %eax,(%esp)
  80148c:	e8 df ff ff ff       	call   801470 <fd2num>
  801491:	05 20 00 0d 00       	add    $0xd0020,%eax
  801496:	c1 e0 0c             	shl    $0xc,%eax
}
  801499:	c9                   	leave  
  80149a:	c3                   	ret    

0080149b <fd_alloc>:
// Returns 0 on success, < 0 on error.  Errors are:
//	-E_MAX_FD: no more file descriptors
// On error, *fd_store is set to 0.
int
fd_alloc(struct Fd **fd_store)
{
  80149b:	55                   	push   %ebp
  80149c:	89 e5                	mov    %esp,%ebp
  80149e:	57                   	push   %edi
  80149f:	56                   	push   %esi
  8014a0:	53                   	push   %ebx
  8014a1:	8b 7d 08             	mov    0x8(%ebp),%edi
	int i;
	struct Fd *fd;

	for (i = 0; i < MAXFD; i++) {
		fd = INDEX2FD(i);
		if ((vpd[PDX(fd)] & PTE_P) == 0 || (vpt[VPN(fd)] & PTE_P) == 0) {
  8014a4:	a1 00 dd 7b ef       	mov    0xef7bdd00,%eax
  8014a9:	a8 01                	test   $0x1,%al
  8014ab:	74 36                	je     8014e3 <fd_alloc+0x48>
  8014ad:	a1 00 00 74 ef       	mov    0xef740000,%eax
  8014b2:	a8 01                	test   $0x1,%al
  8014b4:	74 2d                	je     8014e3 <fd_alloc+0x48>
  8014b6:	b8 00 10 00 d0       	mov    $0xd0001000,%eax
  8014bb:	b9 00 d0 7b ef       	mov    $0xef7bd000,%ecx
  8014c0:	be 00 00 40 ef       	mov    $0xef400000,%esi
  8014c5:	89 c3                	mov    %eax,%ebx
  8014c7:	89 c2                	mov    %eax,%edx
  8014c9:	c1 ea 16             	shr    $0x16,%edx
  8014cc:	8b 14 91             	mov    (%ecx,%edx,4),%edx
  8014cf:	f6 c2 01             	test   $0x1,%dl
  8014d2:	74 14                	je     8014e8 <fd_alloc+0x4d>
  8014d4:	89 c2                	mov    %eax,%edx
  8014d6:	c1 ea 0c             	shr    $0xc,%edx
  8014d9:	8b 14 96             	mov    (%esi,%edx,4),%edx
  8014dc:	f6 c2 01             	test   $0x1,%dl
  8014df:	75 10                	jne    8014f1 <fd_alloc+0x56>
  8014e1:	eb 05                	jmp    8014e8 <fd_alloc+0x4d>
  8014e3:	bb 00 00 00 d0       	mov    $0xd0000000,%ebx
			*fd_store = fd;
  8014e8:	89 1f                	mov    %ebx,(%edi)
  8014ea:	b8 00 00 00 00       	mov    $0x0,%eax
			return 0;
  8014ef:	eb 17                	jmp    801508 <fd_alloc+0x6d>
  8014f1:	05 00 10 00 00       	add    $0x1000,%eax
fd_alloc(struct Fd **fd_store)
{
	int i;
	struct Fd *fd;

	for (i = 0; i < MAXFD; i++) {
  8014f6:	3d 00 00 02 d0       	cmp    $0xd0020000,%eax
  8014fb:	75 c8                	jne    8014c5 <fd_alloc+0x2a>
		if ((vpd[PDX(fd)] & PTE_P) == 0 || (vpt[VPN(fd)] & PTE_P) == 0) {
			*fd_store = fd;
			return 0;
		}
	}
	*fd_store = 0;
  8014fd:	c7 07 00 00 00 00    	movl   $0x0,(%edi)
  801503:	b8 f6 ff ff ff       	mov    $0xfffffff6,%eax
	return -E_MAX_OPEN;
}
  801508:	5b                   	pop    %ebx
  801509:	5e                   	pop    %esi
  80150a:	5f                   	pop    %edi
  80150b:	5d                   	pop    %ebp
  80150c:	c3                   	ret    

0080150d <fd_lookup>:
// Returns 0 on success (the page is in range and mapped), < 0 on error.
// Errors are:
//	-E_INVAL: fdnum was either not in range or not mapped.
int
fd_lookup(int fdnum, struct Fd **fd_store)
{
  80150d:	55                   	push   %ebp
  80150e:	89 e5                	mov    %esp,%ebp
	struct Fd *fd=NULL;

	if (fdnum < 0 || fdnum >= MAXFD) {
  801510:	8b 45 08             	mov    0x8(%ebp),%eax
  801513:	83 f8 1f             	cmp    $0x1f,%eax
  801516:	77 36                	ja     80154e <fd_lookup+0x41>
		if (debug)
			cprintf("[%08x] bad fd %d\n", env->env_id, fd);
		return -E_INVAL;
	}
	fd = INDEX2FD(fdnum);
  801518:	05 00 00 0d 00       	add    $0xd0000,%eax
  80151d:	c1 e0 0c             	shl    $0xc,%eax
	if (!(vpd[PDX(fd)] & PTE_P) || !(vpt[VPN(fd)] & PTE_P)) {
  801520:	89 c2                	mov    %eax,%edx
  801522:	c1 ea 16             	shr    $0x16,%edx
  801525:	8b 14 95 00 d0 7b ef 	mov    -0x10843000(,%edx,4),%edx
  80152c:	f6 c2 01             	test   $0x1,%dl
  80152f:	74 1d                	je     80154e <fd_lookup+0x41>
  801531:	89 c2                	mov    %eax,%edx
  801533:	c1 ea 0c             	shr    $0xc,%edx
  801536:	8b 14 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%edx
  80153d:	f6 c2 01             	test   $0x1,%dl
  801540:	74 0c                	je     80154e <fd_lookup+0x41>
		if (debug)
			cprintf("[%08x] closed fd %d\n", env->env_id, fd);
		return -E_INVAL;
	}
	*fd_store = fd;
  801542:	8b 55 0c             	mov    0xc(%ebp),%edx
  801545:	89 02                	mov    %eax,(%edx)
  801547:	b8 00 00 00 00       	mov    $0x0,%eax
	return 0;
  80154c:	eb 05                	jmp    801553 <fd_lookup+0x46>
  80154e:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
}
  801553:	5d                   	pop    %ebp
  801554:	c3                   	ret    

00801555 <seek>:
	return (*dev->dev_write)(fd, buf, n);
}

int
seek(int fdnum, off_t offset)
{
  801555:	55                   	push   %ebp
  801556:	89 e5                	mov    %esp,%ebp
  801558:	83 ec 18             	sub    $0x18,%esp
	int r;
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0)
  80155b:	8d 45 fc             	lea    -0x4(%ebp),%eax
  80155e:	89 44 24 04          	mov    %eax,0x4(%esp)
  801562:	8b 45 08             	mov    0x8(%ebp),%eax
  801565:	89 04 24             	mov    %eax,(%esp)
  801568:	e8 a0 ff ff ff       	call   80150d <fd_lookup>
  80156d:	85 c0                	test   %eax,%eax
  80156f:	78 0e                	js     80157f <seek+0x2a>
		return r;
	fd->fd_offset = offset;
  801571:	8b 45 fc             	mov    -0x4(%ebp),%eax
  801574:	8b 55 0c             	mov    0xc(%ebp),%edx
  801577:	89 50 04             	mov    %edx,0x4(%eax)
  80157a:	b8 00 00 00 00       	mov    $0x0,%eax
	return 0;
}
  80157f:	c9                   	leave  
  801580:	c3                   	ret    

00801581 <dev_lookup>:
	0
};

int
dev_lookup(int dev_id, struct Dev **dev)
{
  801581:	55                   	push   %ebp
  801582:	89 e5                	mov    %esp,%ebp
  801584:	56                   	push   %esi
  801585:	53                   	push   %ebx
  801586:	83 ec 10             	sub    $0x10,%esp
  801589:	8b 4d 08             	mov    0x8(%ebp),%ecx
  80158c:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	int i;
	for (i = 0; devtab[i]; i++)
		if (devtab[i]->dev_id == dev_id) {
			*dev = devtab[i];
			return 0;
  80158f:	ba 00 00 00 00       	mov    $0x0,%edx
int
dev_lookup(int dev_id, struct Dev **dev)
{
	int i;
	for (i = 0; devtab[i]; i++)
		if (devtab[i]->dev_id == dev_id) {
  801594:	b8 90 87 80 00       	mov    $0x808790,%eax
  801599:	39 0d 90 87 80 00    	cmp    %ecx,0x808790
  80159f:	75 11                	jne    8015b2 <dev_lookup+0x31>
  8015a1:	eb 04                	jmp    8015a7 <dev_lookup+0x26>
  8015a3:	39 08                	cmp    %ecx,(%eax)
  8015a5:	75 10                	jne    8015b7 <dev_lookup+0x36>
			*dev = devtab[i];
  8015a7:	89 03                	mov    %eax,(%ebx)
  8015a9:	b8 00 00 00 00       	mov    $0x0,%eax
			return 0;
  8015ae:	66 90                	xchg   %ax,%ax
  8015b0:	eb 36                	jmp    8015e8 <dev_lookup+0x67>

int
dev_lookup(int dev_id, struct Dev **dev)
{
	int i;
	for (i = 0; devtab[i]; i++)
  8015b2:	be 94 35 80 00       	mov    $0x803594,%esi
  8015b7:	83 c2 01             	add    $0x1,%edx
  8015ba:	8b 04 96             	mov    (%esi,%edx,4),%eax
  8015bd:	85 c0                	test   %eax,%eax
  8015bf:	75 e2                	jne    8015a3 <dev_lookup+0x22>
		if (devtab[i]->dev_id == dev_id) {
			*dev = devtab[i];
			return 0;
		}
	cprintf("[%08x] unknown device type %d\n", env->env_id, dev_id);
  8015c1:	a1 70 9f 80 00       	mov    0x809f70,%eax
  8015c6:	8b 40 4c             	mov    0x4c(%eax),%eax
  8015c9:	89 4c 24 08          	mov    %ecx,0x8(%esp)
  8015cd:	89 44 24 04          	mov    %eax,0x4(%esp)
  8015d1:	c7 04 24 18 35 80 00 	movl   $0x803518,(%esp)
  8015d8:	e8 38 ef ff ff       	call   800515 <cprintf>
	*dev = 0;
  8015dd:	c7 03 00 00 00 00    	movl   $0x0,(%ebx)
  8015e3:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
	return -E_INVAL;
}
  8015e8:	83 c4 10             	add    $0x10,%esp
  8015eb:	5b                   	pop    %ebx
  8015ec:	5e                   	pop    %esi
  8015ed:	5d                   	pop    %ebp
  8015ee:	c3                   	ret    

008015ef <fstat>:
	return (*dev->dev_trunc)(fd, newsize);
}

int
fstat(int fdnum, struct Stat *stat)
{
  8015ef:	55                   	push   %ebp
  8015f0:	89 e5                	mov    %esp,%ebp
  8015f2:	53                   	push   %ebx
  8015f3:	83 ec 24             	sub    $0x24,%esp
  8015f6:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  8015f9:	8d 45 f0             	lea    -0x10(%ebp),%eax
  8015fc:	89 44 24 04          	mov    %eax,0x4(%esp)
  801600:	8b 45 08             	mov    0x8(%ebp),%eax
  801603:	89 04 24             	mov    %eax,(%esp)
  801606:	e8 02 ff ff ff       	call   80150d <fd_lookup>
  80160b:	85 c0                	test   %eax,%eax
  80160d:	78 53                	js     801662 <fstat+0x73>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  80160f:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801612:	89 44 24 04          	mov    %eax,0x4(%esp)
  801616:	8b 45 f0             	mov    -0x10(%ebp),%eax
  801619:	8b 00                	mov    (%eax),%eax
  80161b:	89 04 24             	mov    %eax,(%esp)
  80161e:	e8 5e ff ff ff       	call   801581 <dev_lookup>
{
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  801623:	85 c0                	test   %eax,%eax
  801625:	78 3b                	js     801662 <fstat+0x73>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if (!dev->dev_stat)
  801627:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  80162c:	8b 55 f4             	mov    -0xc(%ebp),%edx
  80162f:	83 7a 14 00          	cmpl   $0x0,0x14(%edx)
  801633:	74 2d                	je     801662 <fstat+0x73>
		return -E_NOT_SUPP;
	stat->st_name[0] = 0;
  801635:	c6 03 00             	movb   $0x0,(%ebx)
	stat->st_size = 0;
  801638:	c7 83 80 00 00 00 00 	movl   $0x0,0x80(%ebx)
  80163f:	00 00 00 
	stat->st_isdir = 0;
  801642:	c7 83 84 00 00 00 00 	movl   $0x0,0x84(%ebx)
  801649:	00 00 00 
	stat->st_dev = dev;
  80164c:	8b 45 f4             	mov    -0xc(%ebp),%eax
  80164f:	89 83 88 00 00 00    	mov    %eax,0x88(%ebx)
	return (*dev->dev_stat)(fd, stat);
  801655:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  801659:	8b 55 f0             	mov    -0x10(%ebp),%edx
  80165c:	89 14 24             	mov    %edx,(%esp)
  80165f:	ff 50 14             	call   *0x14(%eax)
}
  801662:	83 c4 24             	add    $0x24,%esp
  801665:	5b                   	pop    %ebx
  801666:	5d                   	pop    %ebp
  801667:	c3                   	ret    

00801668 <ftruncate>:
	return 0;
}

int
ftruncate(int fdnum, off_t newsize)
{
  801668:	55                   	push   %ebp
  801669:	89 e5                	mov    %esp,%ebp
  80166b:	53                   	push   %ebx
  80166c:	83 ec 24             	sub    $0x24,%esp
  80166f:	8b 5d 08             	mov    0x8(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0
  801672:	8d 45 f0             	lea    -0x10(%ebp),%eax
  801675:	89 44 24 04          	mov    %eax,0x4(%esp)
  801679:	89 1c 24             	mov    %ebx,(%esp)
  80167c:	e8 8c fe ff ff       	call   80150d <fd_lookup>
  801681:	85 c0                	test   %eax,%eax
  801683:	78 5f                	js     8016e4 <ftruncate+0x7c>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  801685:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801688:	89 44 24 04          	mov    %eax,0x4(%esp)
  80168c:	8b 45 f0             	mov    -0x10(%ebp),%eax
  80168f:	8b 00                	mov    (%eax),%eax
  801691:	89 04 24             	mov    %eax,(%esp)
  801694:	e8 e8 fe ff ff       	call   801581 <dev_lookup>
ftruncate(int fdnum, off_t newsize)
{
	int r;
	struct Dev *dev;
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0
  801699:	85 c0                	test   %eax,%eax
  80169b:	78 47                	js     8016e4 <ftruncate+0x7c>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_RDONLY) {
  80169d:	8b 55 f0             	mov    -0x10(%ebp),%edx
  8016a0:	f6 42 08 03          	testb  $0x3,0x8(%edx)
  8016a4:	75 23                	jne    8016c9 <ftruncate+0x61>
		cprintf("[%08x] ftruncate %d -- bad mode\n",
			env->env_id, fdnum); 
  8016a6:	a1 70 9f 80 00       	mov    0x809f70,%eax
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_RDONLY) {
		cprintf("[%08x] ftruncate %d -- bad mode\n",
  8016ab:	8b 40 4c             	mov    0x4c(%eax),%eax
  8016ae:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  8016b2:	89 44 24 04          	mov    %eax,0x4(%esp)
  8016b6:	c7 04 24 38 35 80 00 	movl   $0x803538,(%esp)
  8016bd:	e8 53 ee ff ff       	call   800515 <cprintf>
  8016c2:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
			env->env_id, fdnum); 
		return -E_INVAL;
  8016c7:	eb 1b                	jmp    8016e4 <ftruncate+0x7c>
	}
	if (!dev->dev_trunc)
  8016c9:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8016cc:	8b 48 18             	mov    0x18(%eax),%ecx
  8016cf:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  8016d4:	85 c9                	test   %ecx,%ecx
  8016d6:	74 0c                	je     8016e4 <ftruncate+0x7c>
		return -E_NOT_SUPP;
	return (*dev->dev_trunc)(fd, newsize);
  8016d8:	8b 45 0c             	mov    0xc(%ebp),%eax
  8016db:	89 44 24 04          	mov    %eax,0x4(%esp)
  8016df:	89 14 24             	mov    %edx,(%esp)
  8016e2:	ff d1                	call   *%ecx
}
  8016e4:	83 c4 24             	add    $0x24,%esp
  8016e7:	5b                   	pop    %ebx
  8016e8:	5d                   	pop    %ebp
  8016e9:	c3                   	ret    

008016ea <write>:
	return tot;
}

ssize_t
write(int fdnum, const void *buf, size_t n)
{
  8016ea:	55                   	push   %ebp
  8016eb:	89 e5                	mov    %esp,%ebp
  8016ed:	53                   	push   %ebx
  8016ee:	83 ec 24             	sub    $0x24,%esp
  8016f1:	8b 5d 08             	mov    0x8(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  8016f4:	8d 45 f0             	lea    -0x10(%ebp),%eax
  8016f7:	89 44 24 04          	mov    %eax,0x4(%esp)
  8016fb:	89 1c 24             	mov    %ebx,(%esp)
  8016fe:	e8 0a fe ff ff       	call   80150d <fd_lookup>
  801703:	85 c0                	test   %eax,%eax
  801705:	78 66                	js     80176d <write+0x83>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  801707:	8d 45 f4             	lea    -0xc(%ebp),%eax
  80170a:	89 44 24 04          	mov    %eax,0x4(%esp)
  80170e:	8b 45 f0             	mov    -0x10(%ebp),%eax
  801711:	8b 00                	mov    (%eax),%eax
  801713:	89 04 24             	mov    %eax,(%esp)
  801716:	e8 66 fe ff ff       	call   801581 <dev_lookup>
{
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  80171b:	85 c0                	test   %eax,%eax
  80171d:	78 4e                	js     80176d <write+0x83>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_RDONLY) {
  80171f:	8b 55 f0             	mov    -0x10(%ebp),%edx
  801722:	f6 42 08 03          	testb  $0x3,0x8(%edx)
  801726:	75 23                	jne    80174b <write+0x61>
		cprintf("[%08x] write %d -- bad mode\n", env->env_id, fdnum);
  801728:	a1 70 9f 80 00       	mov    0x809f70,%eax
  80172d:	8b 40 4c             	mov    0x4c(%eax),%eax
  801730:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  801734:	89 44 24 04          	mov    %eax,0x4(%esp)
  801738:	c7 04 24 59 35 80 00 	movl   $0x803559,(%esp)
  80173f:	e8 d1 ed ff ff       	call   800515 <cprintf>
  801744:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
		return -E_INVAL;
  801749:	eb 22                	jmp    80176d <write+0x83>
	}
	if (debug)
		cprintf("write %d %p %d via dev %s\n",
			fdnum, buf, n, dev->dev_name);
	if (!dev->dev_write)
  80174b:	8b 45 f4             	mov    -0xc(%ebp),%eax
  80174e:	8b 48 0c             	mov    0xc(%eax),%ecx
  801751:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  801756:	85 c9                	test   %ecx,%ecx
  801758:	74 13                	je     80176d <write+0x83>
		return -E_NOT_SUPP;
	return (*dev->dev_write)(fd, buf, n);
  80175a:	8b 45 10             	mov    0x10(%ebp),%eax
  80175d:	89 44 24 08          	mov    %eax,0x8(%esp)
  801761:	8b 45 0c             	mov    0xc(%ebp),%eax
  801764:	89 44 24 04          	mov    %eax,0x4(%esp)
  801768:	89 14 24             	mov    %edx,(%esp)
  80176b:	ff d1                	call   *%ecx
}
  80176d:	83 c4 24             	add    $0x24,%esp
  801770:	5b                   	pop    %ebx
  801771:	5d                   	pop    %ebp
  801772:	c3                   	ret    

00801773 <read>:
	return r;
}

ssize_t
read(int fdnum, void *buf, size_t n)
{
  801773:	55                   	push   %ebp
  801774:	89 e5                	mov    %esp,%ebp
  801776:	57                   	push   %edi
  801777:	56                   	push   %esi
  801778:	53                   	push   %ebx
  801779:	83 ec 2c             	sub    $0x2c,%esp
  80177c:	8b 5d 08             	mov    0x8(%ebp),%ebx
  80177f:	8b 75 10             	mov    0x10(%ebp),%esi
	int r;
	int m, tot;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  801782:	8d 45 e0             	lea    -0x20(%ebp),%eax
  801785:	89 44 24 04          	mov    %eax,0x4(%esp)
  801789:	89 1c 24             	mov    %ebx,(%esp)
  80178c:	e8 7c fd ff ff       	call   80150d <fd_lookup>
  801791:	85 c0                	test   %eax,%eax
  801793:	0f 88 b0 00 00 00    	js     801849 <read+0xd6>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  801799:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  80179c:	89 44 24 04          	mov    %eax,0x4(%esp)
  8017a0:	8b 45 e0             	mov    -0x20(%ebp),%eax
  8017a3:	8b 00                	mov    (%eax),%eax
  8017a5:	89 04 24             	mov    %eax,(%esp)
  8017a8:	e8 d4 fd ff ff       	call   801581 <dev_lookup>
	int r;
	int m, tot;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  8017ad:	85 c0                	test   %eax,%eax
  8017af:	0f 88 94 00 00 00    	js     801849 <read+0xd6>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_WRONLY) {
  8017b5:	8b 45 e0             	mov    -0x20(%ebp),%eax
  8017b8:	8b 40 08             	mov    0x8(%eax),%eax
  8017bb:	83 e0 03             	and    $0x3,%eax
  8017be:	83 f8 01             	cmp    $0x1,%eax
  8017c1:	75 23                	jne    8017e6 <read+0x73>
		cprintf("[%08x] read %d -- bad mode\n", env->env_id, fdnum); 
  8017c3:	a1 70 9f 80 00       	mov    0x809f70,%eax
  8017c8:	8b 40 4c             	mov    0x4c(%eax),%eax
  8017cb:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  8017cf:	89 44 24 04          	mov    %eax,0x4(%esp)
  8017d3:	c7 04 24 76 35 80 00 	movl   $0x803576,(%esp)
  8017da:	e8 36 ed ff ff       	call   800515 <cprintf>
  8017df:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
		return -E_INVAL;
  8017e4:	eb 63                	jmp    801849 <read+0xd6>
	}
	if (!dev->dev_read)
  8017e6:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  8017eb:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  8017ee:	83 7a 08 00          	cmpl   $0x0,0x8(%edx)
  8017f2:	74 55                	je     801849 <read+0xd6>
		return -E_NOT_SUPP;

  for (tot = 0; tot < n; tot += m) {
  8017f4:	ba 00 00 00 00       	mov    $0x0,%edx
  8017f9:	bb 00 00 00 00       	mov    $0x0,%ebx
  8017fe:	b8 00 00 00 00       	mov    $0x0,%eax
  801803:	85 f6                	test   %esi,%esi
  801805:	74 42                	je     801849 <read+0xd6>
    int count=0;
    if ((n-tot)/PGSIZE == 0)
  801807:	bf 00 10 00 00       	mov    $0x1000,%edi
  80180c:	89 f0                	mov    %esi,%eax
  80180e:	29 d0                	sub    %edx,%eax
  801810:	89 c1                	mov    %eax,%ecx
  801812:	81 e1 ff 0f 00 00    	and    $0xfff,%ecx
  801818:	3d 00 10 00 00       	cmp    $0x1000,%eax
  80181d:	0f 43 cf             	cmovae %edi,%ecx
      count = (n-tot)%PGSIZE;
    else
      count = PGSIZE;

	  m = (*dev->dev_read)(fd, (char *)buf + tot, count);
  801820:	89 4c 24 08          	mov    %ecx,0x8(%esp)
  801824:	03 55 0c             	add    0xc(%ebp),%edx
  801827:	89 54 24 04          	mov    %edx,0x4(%esp)
  80182b:	8b 45 e0             	mov    -0x20(%ebp),%eax
  80182e:	89 04 24             	mov    %eax,(%esp)
  801831:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  801834:	ff 50 08             	call   *0x8(%eax)
		if (m < 0)
  801837:	85 c0                	test   %eax,%eax
  801839:	78 0e                	js     801849 <read+0xd6>
			return m;
		if (m == 0)
  80183b:	85 c0                	test   %eax,%eax
  80183d:	74 08                	je     801847 <read+0xd4>
		return -E_INVAL;
	}
	if (!dev->dev_read)
		return -E_NOT_SUPP;

  for (tot = 0; tot < n; tot += m) {
  80183f:	01 c3                	add    %eax,%ebx
  801841:	89 da                	mov    %ebx,%edx
  801843:	39 f3                	cmp    %esi,%ebx
  801845:	72 c5                	jb     80180c <read+0x99>
  801847:	89 d8                	mov    %ebx,%eax
			return m;
		if (m == 0)
			break;
	}
	return tot;
}
  801849:	83 c4 2c             	add    $0x2c,%esp
  80184c:	5b                   	pop    %ebx
  80184d:	5e                   	pop    %esi
  80184e:	5f                   	pop    %edi
  80184f:	5d                   	pop    %ebp
  801850:	c3                   	ret    

00801851 <readn>:

ssize_t
readn(int fdnum, void *buf, size_t n)
{
  801851:	55                   	push   %ebp
  801852:	89 e5                	mov    %esp,%ebp
  801854:	57                   	push   %edi
  801855:	56                   	push   %esi
  801856:	53                   	push   %ebx
  801857:	83 ec 1c             	sub    $0x1c,%esp
  80185a:	8b 7d 08             	mov    0x8(%ebp),%edi
  80185d:	8b 75 10             	mov    0x10(%ebp),%esi
	int m, tot;
  struct Fd *fd = INDEX2FD(fdnum);

	for (tot = 0; tot < n; tot += m) {
  801860:	ba 00 00 00 00       	mov    $0x0,%edx
  801865:	bb 00 00 00 00       	mov    $0x0,%ebx
  80186a:	b8 00 00 00 00       	mov    $0x0,%eax
  80186f:	85 f6                	test   %esi,%esi
  801871:	74 29                	je     80189c <readn+0x4b>
		m = read(fdnum, (char*)buf + tot, n - tot);
  801873:	89 f0                	mov    %esi,%eax
  801875:	29 d0                	sub    %edx,%eax
  801877:	89 44 24 08          	mov    %eax,0x8(%esp)
  80187b:	03 55 0c             	add    0xc(%ebp),%edx
  80187e:	89 54 24 04          	mov    %edx,0x4(%esp)
  801882:	89 3c 24             	mov    %edi,(%esp)
  801885:	e8 e9 fe ff ff       	call   801773 <read>
		if (m < 0)
  80188a:	85 c0                	test   %eax,%eax
  80188c:	78 0e                	js     80189c <readn+0x4b>
			return m;
		if (m == 0)
  80188e:	85 c0                	test   %eax,%eax
  801890:	74 08                	je     80189a <readn+0x49>
readn(int fdnum, void *buf, size_t n)
{
	int m, tot;
  struct Fd *fd = INDEX2FD(fdnum);

	for (tot = 0; tot < n; tot += m) {
  801892:	01 c3                	add    %eax,%ebx
  801894:	89 da                	mov    %ebx,%edx
  801896:	39 f3                	cmp    %esi,%ebx
  801898:	72 d9                	jb     801873 <readn+0x22>
  80189a:	89 d8                	mov    %ebx,%eax
			return m;
		if (m == 0)
			break;
	}
	return tot;
}
  80189c:	83 c4 1c             	add    $0x1c,%esp
  80189f:	5b                   	pop    %ebx
  8018a0:	5e                   	pop    %esi
  8018a1:	5f                   	pop    %edi
  8018a2:	5d                   	pop    %ebp
  8018a3:	c3                   	ret    

008018a4 <fd_close>:
// If 'must_exist' is 1, then fd_close returns -E_INVAL when passed a
// closed or nonexistent file descriptor.
// Returns 0 on success, < 0 on error.
int
fd_close(struct Fd *fd, bool must_exist)
{
  8018a4:	55                   	push   %ebp
  8018a5:	89 e5                	mov    %esp,%ebp
  8018a7:	83 ec 28             	sub    $0x28,%esp
  8018aa:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  8018ad:	89 75 fc             	mov    %esi,-0x4(%ebp)
  8018b0:	8b 75 08             	mov    0x8(%ebp),%esi
	struct Fd *fd2;
	struct Dev *dev;
	int r;
	if ((r = fd_lookup(fd2num(fd), &fd2)) < 0
  8018b3:	89 34 24             	mov    %esi,(%esp)
  8018b6:	e8 b5 fb ff ff       	call   801470 <fd2num>
  8018bb:	8d 55 f4             	lea    -0xc(%ebp),%edx
  8018be:	89 54 24 04          	mov    %edx,0x4(%esp)
  8018c2:	89 04 24             	mov    %eax,(%esp)
  8018c5:	e8 43 fc ff ff       	call   80150d <fd_lookup>
  8018ca:	89 c3                	mov    %eax,%ebx
  8018cc:	85 c0                	test   %eax,%eax
  8018ce:	78 05                	js     8018d5 <fd_close+0x31>
  8018d0:	3b 75 f4             	cmp    -0xc(%ebp),%esi
  8018d3:	74 0e                	je     8018e3 <fd_close+0x3f>
	    || fd != fd2)
		return (must_exist ? r : 0);
  8018d5:	83 7d 0c 00          	cmpl   $0x0,0xc(%ebp)
  8018d9:	b8 00 00 00 00       	mov    $0x0,%eax
  8018de:	0f 44 d8             	cmove  %eax,%ebx
  8018e1:	eb 3d                	jmp    801920 <fd_close+0x7c>
	if ((r = dev_lookup(fd->fd_dev_id, &dev)) >= 0) {
  8018e3:	8d 45 f0             	lea    -0x10(%ebp),%eax
  8018e6:	89 44 24 04          	mov    %eax,0x4(%esp)
  8018ea:	8b 06                	mov    (%esi),%eax
  8018ec:	89 04 24             	mov    %eax,(%esp)
  8018ef:	e8 8d fc ff ff       	call   801581 <dev_lookup>
  8018f4:	89 c3                	mov    %eax,%ebx
  8018f6:	85 c0                	test   %eax,%eax
  8018f8:	78 16                	js     801910 <fd_close+0x6c>
		if (dev->dev_close)
  8018fa:	8b 45 f0             	mov    -0x10(%ebp),%eax
  8018fd:	8b 40 10             	mov    0x10(%eax),%eax
  801900:	bb 00 00 00 00       	mov    $0x0,%ebx
  801905:	85 c0                	test   %eax,%eax
  801907:	74 07                	je     801910 <fd_close+0x6c>
			r = (*dev->dev_close)(fd);
  801909:	89 34 24             	mov    %esi,(%esp)
  80190c:	ff d0                	call   *%eax
  80190e:	89 c3                	mov    %eax,%ebx
		else
			r = 0;
	}
	// Make sure fd is unmapped.  Might be a no-op if
	// (*dev->dev_close)(fd) already unmapped it.
	(void) sys_page_unmap(0, fd);
  801910:	89 74 24 04          	mov    %esi,0x4(%esp)
  801914:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  80191b:	e8 6a f9 ff ff       	call   80128a <sys_page_unmap>
	return r;
}
  801920:	89 d8                	mov    %ebx,%eax
  801922:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  801925:	8b 75 fc             	mov    -0x4(%ebp),%esi
  801928:	89 ec                	mov    %ebp,%esp
  80192a:	5d                   	pop    %ebp
  80192b:	c3                   	ret    

0080192c <close>:
	return -E_INVAL;
}

int
close(int fdnum)
{
  80192c:	55                   	push   %ebp
  80192d:	89 e5                	mov    %esp,%ebp
  80192f:	83 ec 28             	sub    $0x28,%esp
	struct Fd *fd;
	int r;

	if ((r = fd_lookup(fdnum, &fd)) < 0)
  801932:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801935:	89 44 24 04          	mov    %eax,0x4(%esp)
  801939:	8b 45 08             	mov    0x8(%ebp),%eax
  80193c:	89 04 24             	mov    %eax,(%esp)
  80193f:	e8 c9 fb ff ff       	call   80150d <fd_lookup>
  801944:	85 c0                	test   %eax,%eax
  801946:	78 13                	js     80195b <close+0x2f>
		return r;
	else
		return fd_close(fd, 1);
  801948:	c7 44 24 04 01 00 00 	movl   $0x1,0x4(%esp)
  80194f:	00 
  801950:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801953:	89 04 24             	mov    %eax,(%esp)
  801956:	e8 49 ff ff ff       	call   8018a4 <fd_close>
}
  80195b:	c9                   	leave  
  80195c:	c3                   	ret    

0080195d <stat>:
	return (*dev->dev_stat)(fd, stat);
}

int
stat(const char *path, struct Stat *stat)
{
  80195d:	55                   	push   %ebp
  80195e:	89 e5                	mov    %esp,%ebp
  801960:	83 ec 18             	sub    $0x18,%esp
  801963:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  801966:	89 75 fc             	mov    %esi,-0x4(%ebp)
	int fd, r;

	if ((fd = open(path, O_RDONLY)) < 0)
  801969:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  801970:	00 
  801971:	8b 45 08             	mov    0x8(%ebp),%eax
  801974:	89 04 24             	mov    %eax,(%esp)
  801977:	e8 80 03 00 00       	call   801cfc <open>
  80197c:	89 c3                	mov    %eax,%ebx
  80197e:	85 c0                	test   %eax,%eax
  801980:	78 1b                	js     80199d <stat+0x40>
		return fd;
	r = fstat(fd, stat);
  801982:	8b 45 0c             	mov    0xc(%ebp),%eax
  801985:	89 44 24 04          	mov    %eax,0x4(%esp)
  801989:	89 1c 24             	mov    %ebx,(%esp)
  80198c:	e8 5e fc ff ff       	call   8015ef <fstat>
  801991:	89 c6                	mov    %eax,%esi
	close(fd);
  801993:	89 1c 24             	mov    %ebx,(%esp)
  801996:	e8 91 ff ff ff       	call   80192c <close>
  80199b:	89 f3                	mov    %esi,%ebx
	return r;
}
  80199d:	89 d8                	mov    %ebx,%eax
  80199f:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  8019a2:	8b 75 fc             	mov    -0x4(%ebp),%esi
  8019a5:	89 ec                	mov    %ebp,%esp
  8019a7:	5d                   	pop    %ebp
  8019a8:	c3                   	ret    

008019a9 <close_all>:
		return fd_close(fd, 1);
}

void
close_all(void)
{
  8019a9:	55                   	push   %ebp
  8019aa:	89 e5                	mov    %esp,%ebp
  8019ac:	53                   	push   %ebx
  8019ad:	83 ec 14             	sub    $0x14,%esp
  8019b0:	bb 00 00 00 00       	mov    $0x0,%ebx
	int i;
	for (i = 0; i < MAXFD; i++)
		close(i);
  8019b5:	89 1c 24             	mov    %ebx,(%esp)
  8019b8:	e8 6f ff ff ff       	call   80192c <close>

void
close_all(void)
{
	int i;
	for (i = 0; i < MAXFD; i++)
  8019bd:	83 c3 01             	add    $0x1,%ebx
  8019c0:	83 fb 20             	cmp    $0x20,%ebx
  8019c3:	75 f0                	jne    8019b5 <close_all+0xc>
		close(i);
}
  8019c5:	83 c4 14             	add    $0x14,%esp
  8019c8:	5b                   	pop    %ebx
  8019c9:	5d                   	pop    %ebp
  8019ca:	c3                   	ret    

008019cb <dup>:
// file and the file offset of the other.
// Closes any previously open file descriptor at 'newfdnum'.
// This is implemented using virtual memory tricks (of course!).
int
dup(int oldfdnum, int newfdnum)
{
  8019cb:	55                   	push   %ebp
  8019cc:	89 e5                	mov    %esp,%ebp
  8019ce:	83 ec 58             	sub    $0x58,%esp
  8019d1:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  8019d4:	89 75 f8             	mov    %esi,-0x8(%ebp)
  8019d7:	89 7d fc             	mov    %edi,-0x4(%ebp)
  8019da:	8b 7d 0c             	mov    0xc(%ebp),%edi
	int r;
	char *ova, *nva;
	pte_t pte;
	struct Fd *oldfd, *newfd;

	if ((r = fd_lookup(oldfdnum, &oldfd)) < 0)
  8019dd:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  8019e0:	89 44 24 04          	mov    %eax,0x4(%esp)
  8019e4:	8b 45 08             	mov    0x8(%ebp),%eax
  8019e7:	89 04 24             	mov    %eax,(%esp)
  8019ea:	e8 1e fb ff ff       	call   80150d <fd_lookup>
  8019ef:	89 c3                	mov    %eax,%ebx
  8019f1:	85 c0                	test   %eax,%eax
  8019f3:	0f 88 e0 00 00 00    	js     801ad9 <dup+0x10e>
		return r;
	close(newfdnum);
  8019f9:	89 3c 24             	mov    %edi,(%esp)
  8019fc:	e8 2b ff ff ff       	call   80192c <close>

	newfd = INDEX2FD(newfdnum);
  801a01:	8d b7 00 00 0d 00    	lea    0xd0000(%edi),%esi
  801a07:	c1 e6 0c             	shl    $0xc,%esi
	ova = fd2data(oldfd);
  801a0a:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  801a0d:	89 04 24             	mov    %eax,(%esp)
  801a10:	e8 6b fa ff ff       	call   801480 <fd2data>
  801a15:	89 c3                	mov    %eax,%ebx
	nva = fd2data(newfd);
  801a17:	89 34 24             	mov    %esi,(%esp)
  801a1a:	e8 61 fa ff ff       	call   801480 <fd2data>
  801a1f:	89 45 d4             	mov    %eax,-0x2c(%ebp)
	if ((vpd[PDX(ova)] & PTE_P) && (vpt[VPN(ova)] & PTE_P))
  801a22:	89 da                	mov    %ebx,%edx
  801a24:	89 d8                	mov    %ebx,%eax
  801a26:	c1 e8 16             	shr    $0x16,%eax
  801a29:	8b 04 85 00 d0 7b ef 	mov    -0x10843000(,%eax,4),%eax
  801a30:	a8 01                	test   $0x1,%al
  801a32:	74 43                	je     801a77 <dup+0xac>
  801a34:	c1 ea 0c             	shr    $0xc,%edx
  801a37:	8b 04 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%eax
  801a3e:	a8 01                	test   $0x1,%al
  801a40:	74 35                	je     801a77 <dup+0xac>
		if ((r = sys_page_map(0, ova, 0, nva, (vpt[VPN(ova)]) & PTE_USER)) < 0)
  801a42:	8b 04 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%eax
  801a49:	25 07 0e 00 00       	and    $0xe07,%eax
  801a4e:	89 44 24 10          	mov    %eax,0x10(%esp)
  801a52:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  801a55:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801a59:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  801a60:	00 
  801a61:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  801a65:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801a6c:	e8 77 f8 ff ff       	call   8012e8 <sys_page_map>
  801a71:	89 c3                	mov    %eax,%ebx
  801a73:	85 c0                	test   %eax,%eax
  801a75:	78 3f                	js     801ab6 <dup+0xeb>
			goto err;
	if ((r = sys_page_map(0, oldfd, 0, newfd, (vpt[VPN(oldfd)]) & PTE_USER)) < 0)
  801a77:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  801a7a:	89 c2                	mov    %eax,%edx
  801a7c:	c1 ea 0c             	shr    $0xc,%edx
  801a7f:	8b 14 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%edx
  801a86:	81 e2 07 0e 00 00    	and    $0xe07,%edx
  801a8c:	89 54 24 10          	mov    %edx,0x10(%esp)
  801a90:	89 74 24 0c          	mov    %esi,0xc(%esp)
  801a94:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  801a9b:	00 
  801a9c:	89 44 24 04          	mov    %eax,0x4(%esp)
  801aa0:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801aa7:	e8 3c f8 ff ff       	call   8012e8 <sys_page_map>
  801aac:	89 c3                	mov    %eax,%ebx
  801aae:	85 c0                	test   %eax,%eax
  801ab0:	78 04                	js     801ab6 <dup+0xeb>
  801ab2:	89 fb                	mov    %edi,%ebx
  801ab4:	eb 23                	jmp    801ad9 <dup+0x10e>
		goto err;

	return newfdnum;
err:
	sys_page_unmap(0, newfd);
  801ab6:	89 74 24 04          	mov    %esi,0x4(%esp)
  801aba:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801ac1:	e8 c4 f7 ff ff       	call   80128a <sys_page_unmap>
	sys_page_unmap(0, nva);
  801ac6:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  801ac9:	89 44 24 04          	mov    %eax,0x4(%esp)
  801acd:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801ad4:	e8 b1 f7 ff ff       	call   80128a <sys_page_unmap>
	return r;
}
  801ad9:	89 d8                	mov    %ebx,%eax
  801adb:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  801ade:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801ae1:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801ae4:	89 ec                	mov    %ebp,%esp
  801ae6:	5d                   	pop    %ebp
  801ae7:	c3                   	ret    

00801ae8 <fsipc>:
// type: request code, passed as the simple integer IPC value.
// dstva: virtual address at which to receive reply page, 0 if none.
// Returns result from the file server.
static int
fsipc(unsigned type, void *dstva)
{
  801ae8:	55                   	push   %ebp
  801ae9:	89 e5                	mov    %esp,%ebp
  801aeb:	53                   	push   %ebx
  801aec:	83 ec 14             	sub    $0x14,%esp
  801aef:	89 d3                	mov    %edx,%ebx
	if (debug)
		cprintf("[%08x] fsipc %d %08x\n", env->env_id, type, *(uint32_t *)&fsipcbuf);

	ipc_send(envs[1].env_id, type, &fsipcbuf, PTE_P | PTE_W | PTE_U);
  801af1:	8b 15 c8 00 c0 ee    	mov    0xeec000c8,%edx
  801af7:	c7 44 24 0c 07 00 00 	movl   $0x7,0xc(%esp)
  801afe:	00 
  801aff:	c7 44 24 08 00 40 80 	movl   $0x804000,0x8(%esp)
  801b06:	00 
  801b07:	89 44 24 04          	mov    %eax,0x4(%esp)
  801b0b:	89 14 24             	mov    %edx,(%esp)
  801b0e:	e8 cd 11 00 00       	call   802ce0 <ipc_send>
	return ipc_recv(NULL, dstva, NULL);
  801b13:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  801b1a:	00 
  801b1b:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  801b1f:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801b26:	e8 27 12 00 00       	call   802d52 <ipc_recv>
}
  801b2b:	83 c4 14             	add    $0x14,%esp
  801b2e:	5b                   	pop    %ebx
  801b2f:	5d                   	pop    %ebp
  801b30:	c3                   	ret    

00801b31 <devfile_trunc>:
}

// Truncate or extend an open file to 'size' bytes
static int
devfile_trunc(struct Fd *fd, off_t newsize)
{
  801b31:	55                   	push   %ebp
  801b32:	89 e5                	mov    %esp,%ebp
  801b34:	83 ec 08             	sub    $0x8,%esp
	fsipcbuf.set_size.req_fileid = fd->fd_file.id;
  801b37:	8b 45 08             	mov    0x8(%ebp),%eax
  801b3a:	8b 40 0c             	mov    0xc(%eax),%eax
  801b3d:	a3 00 40 80 00       	mov    %eax,0x804000
	fsipcbuf.set_size.req_size = newsize;
  801b42:	8b 45 0c             	mov    0xc(%ebp),%eax
  801b45:	a3 04 40 80 00       	mov    %eax,0x804004
	return fsipc(FSREQ_SET_SIZE, NULL);
  801b4a:	ba 00 00 00 00       	mov    $0x0,%edx
  801b4f:	b8 02 00 00 00       	mov    $0x2,%eax
  801b54:	e8 8f ff ff ff       	call   801ae8 <fsipc>
}
  801b59:	c9                   	leave  
  801b5a:	c3                   	ret    

00801b5b <devfile_flush>:
// open, unmapping it is enough to free up server-side resources.
// Other than that, we just have to make sure our changes are flushed
// to disk.
static int
devfile_flush(struct Fd *fd)
{
  801b5b:	55                   	push   %ebp
  801b5c:	89 e5                	mov    %esp,%ebp
  801b5e:	83 ec 08             	sub    $0x8,%esp
	fsipcbuf.flush.req_fileid = fd->fd_file.id;
  801b61:	8b 45 08             	mov    0x8(%ebp),%eax
  801b64:	8b 40 0c             	mov    0xc(%eax),%eax
  801b67:	a3 00 40 80 00       	mov    %eax,0x804000
	return fsipc(FSREQ_FLUSH, NULL);
  801b6c:	ba 00 00 00 00       	mov    $0x0,%edx
  801b71:	b8 06 00 00 00       	mov    $0x6,%eax
  801b76:	e8 6d ff ff ff       	call   801ae8 <fsipc>
}
  801b7b:	c9                   	leave  
  801b7c:	c3                   	ret    

00801b7d <sync>:
}

// Synchronize disk with buffer cache
int
sync(void)
{
  801b7d:	55                   	push   %ebp
  801b7e:	89 e5                	mov    %esp,%ebp
  801b80:	83 ec 08             	sub    $0x8,%esp
	// Ask the file server to update the disk
	// by writing any dirty blocks in the buffer cache.

	return fsipc(FSREQ_SYNC, NULL);
  801b83:	ba 00 00 00 00       	mov    $0x0,%edx
  801b88:	b8 08 00 00 00       	mov    $0x8,%eax
  801b8d:	e8 56 ff ff ff       	call   801ae8 <fsipc>
}
  801b92:	c9                   	leave  
  801b93:	c3                   	ret    

00801b94 <devfile_stat>:
    return n;
}

static int
devfile_stat(struct Fd *fd, struct Stat *st)
{
  801b94:	55                   	push   %ebp
  801b95:	89 e5                	mov    %esp,%ebp
  801b97:	53                   	push   %ebx
  801b98:	83 ec 14             	sub    $0x14,%esp
  801b9b:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	int r;

	fsipcbuf.stat.req_fileid = fd->fd_file.id;
  801b9e:	8b 45 08             	mov    0x8(%ebp),%eax
  801ba1:	8b 40 0c             	mov    0xc(%eax),%eax
  801ba4:	a3 00 40 80 00       	mov    %eax,0x804000
	if ((r = fsipc(FSREQ_STAT, NULL)) < 0)
  801ba9:	ba 00 00 00 00       	mov    $0x0,%edx
  801bae:	b8 05 00 00 00       	mov    $0x5,%eax
  801bb3:	e8 30 ff ff ff       	call   801ae8 <fsipc>
  801bb8:	85 c0                	test   %eax,%eax
  801bba:	78 2b                	js     801be7 <devfile_stat+0x53>
		return r;
	strcpy(st->st_name, fsipcbuf.statRet.ret_name);
  801bbc:	c7 44 24 04 00 40 80 	movl   $0x804000,0x4(%esp)
  801bc3:	00 
  801bc4:	89 1c 24             	mov    %ebx,(%esp)
  801bc7:	e8 1e f0 ff ff       	call   800bea <strcpy>
	st->st_size = fsipcbuf.statRet.ret_size;
  801bcc:	a1 80 40 80 00       	mov    0x804080,%eax
  801bd1:	89 83 80 00 00 00    	mov    %eax,0x80(%ebx)
	st->st_isdir = fsipcbuf.statRet.ret_isdir;
  801bd7:	a1 84 40 80 00       	mov    0x804084,%eax
  801bdc:	89 83 84 00 00 00    	mov    %eax,0x84(%ebx)
  801be2:	b8 00 00 00 00       	mov    $0x0,%eax
	return 0;
}
  801be7:	83 c4 14             	add    $0x14,%esp
  801bea:	5b                   	pop    %ebx
  801beb:	5d                   	pop    %ebp
  801bec:	c3                   	ret    

00801bed <devfile_write>:
// Returns:
//	 The number of bytes successfully written.
//	 < 0 on error.
static ssize_t
devfile_write(struct Fd *fd, const void *buf, size_t n)
{
  801bed:	55                   	push   %ebp
  801bee:	89 e5                	mov    %esp,%ebp
  801bf0:	53                   	push   %ebx
  801bf1:	83 ec 14             	sub    $0x14,%esp
  801bf4:	8b 45 08             	mov    0x8(%ebp),%eax
  801bf7:	8b 55 0c             	mov    0xc(%ebp),%edx
  801bfa:	8b 5d 10             	mov    0x10(%ebp),%ebx
	// careful: fsipcbuf.write.req_buf is only so large, but
	// remember that write is always allowed to write *fewer*
	// bytes than requested.
	// LAB 5: Your code here
    int r;
    if (!fd || !buf || (n>(PGSIZE-sizeof(size_t)-sizeof(int))))
  801bfd:	85 c0                	test   %eax,%eax
  801bff:	74 44                	je     801c45 <devfile_write+0x58>
  801c01:	85 d2                	test   %edx,%edx
  801c03:	74 40                	je     801c45 <devfile_write+0x58>
  801c05:	81 fb f8 0f 00 00    	cmp    $0xff8,%ebx
  801c0b:	77 38                	ja     801c45 <devfile_write+0x58>
        return -E_INVAL;

    fsipcbuf.write.req_fileid   = fd->fd_file.id;
  801c0d:	8b 40 0c             	mov    0xc(%eax),%eax
  801c10:	a3 00 40 80 00       	mov    %eax,0x804000
    fsipcbuf.write.req_n        = n;
  801c15:	89 1d 04 40 80 00    	mov    %ebx,0x804004
    memmove(fsipcbuf.write.req_buf, buf, n);
  801c1b:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  801c1f:	89 54 24 04          	mov    %edx,0x4(%esp)
  801c23:	c7 04 24 08 40 80 00 	movl   $0x804008,(%esp)
  801c2a:	e8 76 f1 ff ff       	call   800da5 <memmove>
    if ((r=fsipc(FSREQ_WRITE, NULL))<0)
  801c2f:	ba 00 00 00 00       	mov    $0x0,%edx
  801c34:	b8 04 00 00 00       	mov    $0x4,%eax
  801c39:	e8 aa fe ff ff       	call   801ae8 <fsipc>
        return r;
    return n;
  801c3e:	85 c0                	test   %eax,%eax
  801c40:	0f 49 c3             	cmovns %ebx,%eax
  801c43:	eb 05                	jmp    801c4a <devfile_write+0x5d>
  801c45:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
}
  801c4a:	83 c4 14             	add    $0x14,%esp
  801c4d:	5b                   	pop    %ebx
  801c4e:	5d                   	pop    %ebp
  801c4f:	c3                   	ret    

00801c50 <devfile_read>:
// Returns:
// 	The number of bytes successfully read.
// 	< 0 on error.
static ssize_t
devfile_read(struct Fd *fd, void *buf, size_t n)
{
  801c50:	55                   	push   %ebp
  801c51:	89 e5                	mov    %esp,%ebp
  801c53:	83 ec 18             	sub    $0x18,%esp
  801c56:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  801c59:	89 75 fc             	mov    %esi,-0x4(%ebp)
  801c5c:	8b 45 08             	mov    0x8(%ebp),%eax
  801c5f:	8b 75 0c             	mov    0xc(%ebp),%esi
	// filling fsipcbuf.read with the request arguments.  The
	// bytes read will be written back to fsipcbuf by the file
	// system server.
	// LAB 5: Your code here
  int r;
  if (!fd || !buf)
  801c62:	85 c0                	test   %eax,%eax
  801c64:	74 04                	je     801c6a <devfile_read+0x1a>
  801c66:	85 f6                	test   %esi,%esi
  801c68:	75 07                	jne    801c71 <devfile_read+0x21>
  801c6a:	bb fd ff ff ff       	mov    $0xfffffffd,%ebx
  801c6f:	eb 39                	jmp    801caa <devfile_read+0x5a>
    return -E_INVAL;

  fsipcbuf.read.req_fileid    = fd->fd_file.id;
  801c71:	8b 40 0c             	mov    0xc(%eax),%eax
  801c74:	a3 00 40 80 00       	mov    %eax,0x804000
  fsipcbuf.read.req_n         = n;
  801c79:	8b 45 10             	mov    0x10(%ebp),%eax
  801c7c:	a3 04 40 80 00       	mov    %eax,0x804004
  if ((r=fsipc(FSREQ_READ, NULL))<0)
  801c81:	ba 00 00 00 00       	mov    $0x0,%edx
  801c86:	b8 03 00 00 00       	mov    $0x3,%eax
  801c8b:	e8 58 fe ff ff       	call   801ae8 <fsipc>
  801c90:	89 c3                	mov    %eax,%ebx
  801c92:	85 c0                	test   %eax,%eax
  801c94:	78 14                	js     801caa <devfile_read+0x5a>
    return r;

  memmove(buf, fsipcbuf.readRet.ret_buf, r);
  801c96:	89 44 24 08          	mov    %eax,0x8(%esp)
  801c9a:	c7 44 24 04 00 40 80 	movl   $0x804000,0x4(%esp)
  801ca1:	00 
  801ca2:	89 34 24             	mov    %esi,(%esp)
  801ca5:	e8 fb f0 ff ff       	call   800da5 <memmove>
  return r;
}
  801caa:	89 d8                	mov    %ebx,%eax
  801cac:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  801caf:	8b 75 fc             	mov    -0x4(%ebp),%esi
  801cb2:	89 ec                	mov    %ebp,%esp
  801cb4:	5d                   	pop    %ebp
  801cb5:	c3                   	ret    

00801cb6 <remove>:
}

// Delete a file
int
remove(const char *path)
{
  801cb6:	55                   	push   %ebp
  801cb7:	89 e5                	mov    %esp,%ebp
  801cb9:	53                   	push   %ebx
  801cba:	83 ec 14             	sub    $0x14,%esp
  801cbd:	8b 5d 08             	mov    0x8(%ebp),%ebx
	if (strlen(path) >= MAXPATHLEN)
  801cc0:	89 1c 24             	mov    %ebx,(%esp)
  801cc3:	e8 d8 ee ff ff       	call   800ba0 <strlen>
  801cc8:	89 c2                	mov    %eax,%edx
  801cca:	b8 f4 ff ff ff       	mov    $0xfffffff4,%eax
  801ccf:	81 fa ff 03 00 00    	cmp    $0x3ff,%edx
  801cd5:	7f 1f                	jg     801cf6 <remove+0x40>
		return -E_BAD_PATH;
	strcpy(fsipcbuf.remove.req_path, path);
  801cd7:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  801cdb:	c7 04 24 00 40 80 00 	movl   $0x804000,(%esp)
  801ce2:	e8 03 ef ff ff       	call   800bea <strcpy>
	return fsipc(FSREQ_REMOVE, NULL);
  801ce7:	ba 00 00 00 00       	mov    $0x0,%edx
  801cec:	b8 07 00 00 00       	mov    $0x7,%eax
  801cf1:	e8 f2 fd ff ff       	call   801ae8 <fsipc>
}
  801cf6:	83 c4 14             	add    $0x14,%esp
  801cf9:	5b                   	pop    %ebx
  801cfa:	5d                   	pop    %ebp
  801cfb:	c3                   	ret    

00801cfc <open>:
// 	The file descriptor index on success
// 	-E_BAD_PATH if the path is too long (>= MAXPATHLEN)
// 	< 0 for other errors.
int
open(const char *path, int mode)
{
  801cfc:	55                   	push   %ebp
  801cfd:	89 e5                	mov    %esp,%ebp
  801cff:	83 ec 28             	sub    $0x28,%esp
  801d02:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  801d05:	89 75 fc             	mov    %esi,-0x4(%ebp)
  801d08:	8b 75 08             	mov    0x8(%ebp),%esi
	// Return the file descriptor index.
	// If any step after fd_alloc fails, use fd_close to free the
  struct Fd *f    = NULL;
  int r   = 0;

  if (!path)
  801d0b:	bb fd ff ff ff       	mov    $0xfffffffd,%ebx
  801d10:	85 f6                	test   %esi,%esi
  801d12:	74 65                	je     801d79 <open+0x7d>
	// (fd_alloc does not allocate a page, it just returns an
	// unused fd address.  Do you need to allocate a page?)
	//
	// Return the file descriptor index.
	// If any step after fd_alloc fails, use fd_close to free the
  struct Fd *f    = NULL;
  801d14:	c7 45 f4 00 00 00 00 	movl   $0x0,-0xc(%ebp)
  int r   = 0;

  if (!path)
    return -E_INVAL;
  if((r=fd_alloc(&f))<0)
  801d1b:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801d1e:	89 04 24             	mov    %eax,(%esp)
  801d21:	e8 75 f7 ff ff       	call   80149b <fd_alloc>
  801d26:	89 c3                	mov    %eax,%ebx
  801d28:	85 c0                	test   %eax,%eax
  801d2a:	78 4d                	js     801d79 <open+0x7d>
    return r;

	strcpy(fsipcbuf.open.req_path, path);
  801d2c:	89 74 24 04          	mov    %esi,0x4(%esp)
  801d30:	c7 04 24 00 40 80 00 	movl   $0x804000,(%esp)
  801d37:	e8 ae ee ff ff       	call   800bea <strcpy>
	fsipcbuf.open.req_omode = mode;
  801d3c:	8b 45 0c             	mov    0xc(%ebp),%eax
  801d3f:	a3 00 44 80 00       	mov    %eax,0x804400

  if ((r=fsipc(FSREQ_OPEN, f))<0) {
  801d44:	8b 55 f4             	mov    -0xc(%ebp),%edx
  801d47:	b8 01 00 00 00       	mov    $0x1,%eax
  801d4c:	e8 97 fd ff ff       	call   801ae8 <fsipc>
  801d51:	89 c3                	mov    %eax,%ebx
  801d53:	85 c0                	test   %eax,%eax
  801d55:	79 15                	jns    801d6c <open+0x70>
    fd_close(f, 0);
  801d57:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  801d5e:	00 
  801d5f:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801d62:	89 04 24             	mov    %eax,(%esp)
  801d65:	e8 3a fb ff ff       	call   8018a4 <fd_close>
    return r;
  801d6a:	eb 0d                	jmp    801d79 <open+0x7d>
  }
  return fd2num(f);
  801d6c:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801d6f:	89 04 24             	mov    %eax,(%esp)
  801d72:	e8 f9 f6 ff ff       	call   801470 <fd2num>
  801d77:	89 c3                	mov    %eax,%ebx
}
  801d79:	89 d8                	mov    %ebx,%eax
  801d7b:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  801d7e:	8b 75 fc             	mov    -0x4(%ebp),%esi
  801d81:	89 ec                	mov    %ebp,%esp
  801d83:	5d                   	pop    %ebp
  801d84:	c3                   	ret    
  801d85:	00 00                	add    %al,(%eax)
	...

00801d88 <spawn>:
// argv: pointer to null-terminated array of pointers to strings,
// 	 which will be passed to the child as its command-line arguments.
// Returns child envid on success, < 0 on failure.
int
spawn(const char *prog, const char **argv)
{
  801d88:	55                   	push   %ebp
  801d89:	89 e5                	mov    %esp,%ebp
  801d8b:	57                   	push   %edi
  801d8c:	56                   	push   %esi
  801d8d:	53                   	push   %ebx
  801d8e:	81 ec 9c 02 00 00    	sub    $0x29c,%esp
	//   - Call sys_env_set_trapframe(child, &child_tf) to set up the
	//     correct initial eip and esp values in the child.
	//
	//   - Start the child process running with sys_env_set_status().

	if ((r = open(prog, O_RDONLY)) < 0)
  801d94:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  801d9b:	00 
  801d9c:	8b 45 08             	mov    0x8(%ebp),%eax
  801d9f:	89 04 24             	mov    %eax,(%esp)
  801da2:	e8 55 ff ff ff       	call   801cfc <open>
  801da7:	89 85 88 fd ff ff    	mov    %eax,-0x278(%ebp)
  801dad:	89 c3                	mov    %eax,%ebx
  801daf:	85 c0                	test   %eax,%eax
  801db1:	0f 88 e0 05 00 00    	js     802397 <spawn+0x60f>
	fd = r;

	// Read elf header
	elf = (struct Elf*) elf_buf;
	if (read(fd, elf_buf, sizeof(elf_buf)) != sizeof(elf_buf)
	    || elf->e_magic != ELF_MAGIC) {
  801db7:	c7 44 24 08 00 02 00 	movl   $0x200,0x8(%esp)
  801dbe:	00 
  801dbf:	8d 85 e8 fd ff ff    	lea    -0x218(%ebp),%eax
  801dc5:	89 44 24 04          	mov    %eax,0x4(%esp)
  801dc9:	89 1c 24             	mov    %ebx,(%esp)
  801dcc:	e8 a2 f9 ff ff       	call   801773 <read>
		return r;
	fd = r;

	// Read elf header
	elf = (struct Elf*) elf_buf;
	if (read(fd, elf_buf, sizeof(elf_buf)) != sizeof(elf_buf)
  801dd1:	3d 00 02 00 00       	cmp    $0x200,%eax
  801dd6:	75 0c                	jne    801de4 <spawn+0x5c>
	    || elf->e_magic != ELF_MAGIC) {
  801dd8:	81 bd e8 fd ff ff 7f 	cmpl   $0x464c457f,-0x218(%ebp)
  801ddf:	45 4c 46 
  801de2:	74 36                	je     801e1a <spawn+0x92>
		close(fd);
  801de4:	8b 85 88 fd ff ff    	mov    -0x278(%ebp),%eax
  801dea:	89 04 24             	mov    %eax,(%esp)
  801ded:	e8 3a fb ff ff       	call   80192c <close>
		cprintf("elf magic %08x want %08x\n", elf->e_magic, ELF_MAGIC);
  801df2:	c7 44 24 08 7f 45 4c 	movl   $0x464c457f,0x8(%esp)
  801df9:	46 
  801dfa:	8b 85 e8 fd ff ff    	mov    -0x218(%ebp),%eax
  801e00:	89 44 24 04          	mov    %eax,0x4(%esp)
  801e04:	c7 04 24 a8 35 80 00 	movl   $0x8035a8,(%esp)
  801e0b:	e8 05 e7 ff ff       	call   800515 <cprintf>
  801e10:	bb f2 ff ff ff       	mov    $0xfffffff2,%ebx
		return -E_NOT_EXEC;
  801e15:	e9 7d 05 00 00       	jmp    802397 <spawn+0x60f>
static __inline envid_t sys_exofork(void) __attribute__((always_inline));
static __inline envid_t
sys_exofork(void)
{
	envid_t ret;
	__asm __volatile("int %2"
  801e1a:	ba 07 00 00 00       	mov    $0x7,%edx
  801e1f:	89 d0                	mov    %edx,%eax
  801e21:	cd 30                	int    $0x30
  801e23:	89 85 84 fd ff ff    	mov    %eax,-0x27c(%ebp)
	}

	// Create new child environment
	if ((r = sys_exofork()) < 0)
  801e29:	85 c0                	test   %eax,%eax
  801e2b:	0f 88 60 05 00 00    	js     802391 <spawn+0x609>
		return r;
	child = r;

	// Set up trap frame, including initial stack.
	child_tf = envs[ENVX(child)].env_tf;
  801e31:	89 c6                	mov    %eax,%esi
  801e33:	81 e6 ff 03 00 00    	and    $0x3ff,%esi
  801e39:	6b f6 7c             	imul   $0x7c,%esi,%esi
  801e3c:	8d bd a4 fd ff ff    	lea    -0x25c(%ebp),%edi
  801e42:	81 c6 00 00 c0 ee    	add    $0xeec00000,%esi
  801e48:	b9 11 00 00 00       	mov    $0x11,%ecx
  801e4d:	f3 a5                	rep movsl %ds:(%esi),%es:(%edi)
	child_tf.tf_eip = elf->e_entry;
  801e4f:	8b 85 00 fe ff ff    	mov    -0x200(%ebp),%eax
  801e55:	89 85 d4 fd ff ff    	mov    %eax,-0x22c(%ebp)
	uintptr_t *argv_store;

	// Count the number of arguments (argc)
	// and the total amount of space needed for strings (string_size).
	string_size = 0;
	for (argc = 0; argv[argc] != 0; argc++)
  801e5b:	8b 55 0c             	mov    0xc(%ebp),%edx
  801e5e:	8b 02                	mov    (%edx),%eax
  801e60:	bb 00 00 00 00       	mov    $0x0,%ebx
  801e65:	be 00 00 00 00       	mov    $0x0,%esi
  801e6a:	85 c0                	test   %eax,%eax
  801e6c:	75 16                	jne    801e84 <spawn+0xfc>
  801e6e:	c7 85 7c fd ff ff 00 	movl   $0x0,-0x284(%ebp)
  801e75:	00 00 00 
  801e78:	c7 85 78 fd ff ff 00 	movl   $0x0,-0x288(%ebp)
  801e7f:	00 00 00 
  801e82:	eb 2c                	jmp    801eb0 <spawn+0x128>
  801e84:	8b 7d 0c             	mov    0xc(%ebp),%edi
		string_size += strlen(argv[argc]) + 1;
  801e87:	89 04 24             	mov    %eax,(%esp)
  801e8a:	e8 11 ed ff ff       	call   800ba0 <strlen>
  801e8f:	8d 5c 18 01          	lea    0x1(%eax,%ebx,1),%ebx
	uintptr_t *argv_store;

	// Count the number of arguments (argc)
	// and the total amount of space needed for strings (string_size).
	string_size = 0;
	for (argc = 0; argv[argc] != 0; argc++)
  801e93:	83 c6 01             	add    $0x1,%esi
  801e96:	8d 14 b5 00 00 00 00 	lea    0x0(,%esi,4),%edx
  801e9d:	8b 04 b7             	mov    (%edi,%esi,4),%eax
  801ea0:	85 c0                	test   %eax,%eax
  801ea2:	75 e3                	jne    801e87 <spawn+0xff>
  801ea4:	89 95 7c fd ff ff    	mov    %edx,-0x284(%ebp)
  801eaa:	89 b5 78 fd ff ff    	mov    %esi,-0x288(%ebp)
	// Determine where to place the strings and the argv array.
	// Set up pointers into the temporary page 'UTEMP'; we'll map a page
	// there later, then remap that page into the child environment
	// at (USTACKTOP - PGSIZE).
	// strings is the topmost thing on the stack.
	string_store = (char*) UTEMP + PGSIZE - string_size;
  801eb0:	f7 db                	neg    %ebx
  801eb2:	8d bb 00 10 40 00    	lea    0x401000(%ebx),%edi
	// argv is below that.  There's one argument pointer per argument, plus
	// a null pointer.
	argv_store = (uintptr_t*) (ROUNDDOWN(string_store, 4) - 4 * (argc + 1));
  801eb8:	89 fa                	mov    %edi,%edx
  801eba:	83 e2 fc             	and    $0xfffffffc,%edx
  801ebd:	89 f0                	mov    %esi,%eax
  801ebf:	f7 d0                	not    %eax
  801ec1:	8d 04 82             	lea    (%edx,%eax,4),%eax
  801ec4:	89 85 94 fd ff ff    	mov    %eax,-0x26c(%ebp)
	
	// Make sure that argv, strings, and the 2 words that hold 'argc'
	// and 'argv' themselves will all fit in a single stack page.
	if ((void*) (argv_store - 2) < (void*) UTEMP)
  801eca:	83 e8 08             	sub    $0x8,%eax
  801ecd:	89 85 80 fd ff ff    	mov    %eax,-0x280(%ebp)
	return child;

error:
	sys_env_destroy(child);
	close(fd);
	return r;
  801ed3:	bb fc ff ff ff       	mov    $0xfffffffc,%ebx
	// a null pointer.
	argv_store = (uintptr_t*) (ROUNDDOWN(string_store, 4) - 4 * (argc + 1));
	
	// Make sure that argv, strings, and the 2 words that hold 'argc'
	// and 'argv' themselves will all fit in a single stack page.
	if ((void*) (argv_store - 2) < (void*) UTEMP)
  801ed8:	3d ff ff 3f 00       	cmp    $0x3fffff,%eax
  801edd:	0f 86 b4 04 00 00    	jbe    802397 <spawn+0x60f>
		return -E_NO_MEM;

	// Allocate the single stack page at UTEMP.
	if ((r = sys_page_alloc(0, (void*) UTEMP, PTE_P|PTE_U|PTE_W)) < 0)
  801ee3:	c7 44 24 08 07 00 00 	movl   $0x7,0x8(%esp)
  801eea:	00 
  801eeb:	c7 44 24 04 00 00 40 	movl   $0x400000,0x4(%esp)
  801ef2:	00 
  801ef3:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801efa:	e8 47 f4 ff ff       	call   801346 <sys_page_alloc>
  801eff:	89 c3                	mov    %eax,%ebx
  801f01:	85 c0                	test   %eax,%eax
  801f03:	0f 88 8e 04 00 00    	js     802397 <spawn+0x60f>
	//	  (Again, argv should use an address valid in the child's
	//	  environment.)
	//
	//	* Set *init_esp to the initial stack pointer for the child,
	//	  (Again, use an address valid in the child's environment.)
	for (i = 0; i < argc; i++) {
  801f09:	85 f6                	test   %esi,%esi
  801f0b:	7e 46                	jle    801f53 <spawn+0x1cb>
  801f0d:	bb 00 00 00 00       	mov    $0x0,%ebx
  801f12:	89 b5 8c fd ff ff    	mov    %esi,-0x274(%ebp)
  801f18:	8b 75 0c             	mov    0xc(%ebp),%esi
		argv_store[i] = UTEMP2USTACK(string_store);
  801f1b:	8d 87 00 d0 7f ee    	lea    -0x11803000(%edi),%eax
  801f21:	8b 95 94 fd ff ff    	mov    -0x26c(%ebp),%edx
  801f27:	89 04 9a             	mov    %eax,(%edx,%ebx,4)
		strcpy(string_store, argv[i]);
  801f2a:	8b 04 9e             	mov    (%esi,%ebx,4),%eax
  801f2d:	89 44 24 04          	mov    %eax,0x4(%esp)
  801f31:	89 3c 24             	mov    %edi,(%esp)
  801f34:	e8 b1 ec ff ff       	call   800bea <strcpy>
		string_store += strlen(argv[i]) + 1;
  801f39:	8b 04 9e             	mov    (%esi,%ebx,4),%eax
  801f3c:	89 04 24             	mov    %eax,(%esp)
  801f3f:	e8 5c ec ff ff       	call   800ba0 <strlen>
  801f44:	8d 7c 38 01          	lea    0x1(%eax,%edi,1),%edi
	//	  (Again, argv should use an address valid in the child's
	//	  environment.)
	//
	//	* Set *init_esp to the initial stack pointer for the child,
	//	  (Again, use an address valid in the child's environment.)
	for (i = 0; i < argc; i++) {
  801f48:	83 c3 01             	add    $0x1,%ebx
  801f4b:	3b 9d 8c fd ff ff    	cmp    -0x274(%ebp),%ebx
  801f51:	7c c8                	jl     801f1b <spawn+0x193>
		argv_store[i] = UTEMP2USTACK(string_store);
		strcpy(string_store, argv[i]);
		string_store += strlen(argv[i]) + 1;
	}
	argv_store[argc] = 0;
  801f53:	8b 95 94 fd ff ff    	mov    -0x26c(%ebp),%edx
  801f59:	8b 85 7c fd ff ff    	mov    -0x284(%ebp),%eax
  801f5f:	c7 04 02 00 00 00 00 	movl   $0x0,(%edx,%eax,1)
	assert(string_store == (char*)UTEMP + PGSIZE);
  801f66:	81 ff 00 10 40 00    	cmp    $0x401000,%edi
  801f6c:	74 24                	je     801f92 <spawn+0x20a>
  801f6e:	c7 44 24 0c 48 36 80 	movl   $0x803648,0xc(%esp)
  801f75:	00 
  801f76:	c7 44 24 08 c2 35 80 	movl   $0x8035c2,0x8(%esp)
  801f7d:	00 
  801f7e:	c7 44 24 04 d9 00 00 	movl   $0xd9,0x4(%esp)
  801f85:	00 
  801f86:	c7 04 24 d7 35 80 00 	movl   $0x8035d7,(%esp)
  801f8d:	e8 be e4 ff ff       	call   800450 <_panic>

	argv_store[-1] = UTEMP2USTACK(argv_store);
  801f92:	8b 85 94 fd ff ff    	mov    -0x26c(%ebp),%eax
  801f98:	2d 00 30 80 11       	sub    $0x11803000,%eax
  801f9d:	8b 95 94 fd ff ff    	mov    -0x26c(%ebp),%edx
  801fa3:	89 42 fc             	mov    %eax,-0x4(%edx)
	argv_store[-2] = argc;
  801fa6:	8b 95 78 fd ff ff    	mov    -0x288(%ebp),%edx
  801fac:	8b 85 80 fd ff ff    	mov    -0x280(%ebp),%eax
  801fb2:	89 10                	mov    %edx,(%eax)

	*init_esp = UTEMP2USTACK(&argv_store[-2]);
  801fb4:	8b 85 94 fd ff ff    	mov    -0x26c(%ebp),%eax
  801fba:	2d 08 30 80 11       	sub    $0x11803008,%eax
  801fbf:	89 85 e0 fd ff ff    	mov    %eax,-0x220(%ebp)

	// After completing the stack, map it into the child's address space
	// and unmap it from ours!
	if ((r = sys_page_map(0, UTEMP, child, (void*) (USTACKTOP - PGSIZE), PTE_P | PTE_U | PTE_W)) < 0)
  801fc5:	c7 44 24 10 07 00 00 	movl   $0x7,0x10(%esp)
  801fcc:	00 
  801fcd:	c7 44 24 0c 00 d0 bf 	movl   $0xeebfd000,0xc(%esp)
  801fd4:	ee 
  801fd5:	8b 85 84 fd ff ff    	mov    -0x27c(%ebp),%eax
  801fdb:	89 44 24 08          	mov    %eax,0x8(%esp)
  801fdf:	c7 44 24 04 00 00 40 	movl   $0x400000,0x4(%esp)
  801fe6:	00 
  801fe7:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801fee:	e8 f5 f2 ff ff       	call   8012e8 <sys_page_map>
  801ff3:	89 c3                	mov    %eax,%ebx
  801ff5:	85 c0                	test   %eax,%eax
  801ff7:	78 1a                	js     802013 <spawn+0x28b>
		goto error;
	if ((r = sys_page_unmap(0, UTEMP)) < 0)
  801ff9:	c7 44 24 04 00 00 40 	movl   $0x400000,0x4(%esp)
  802000:	00 
  802001:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802008:	e8 7d f2 ff ff       	call   80128a <sys_page_unmap>
  80200d:	89 c3                	mov    %eax,%ebx
  80200f:	85 c0                	test   %eax,%eax
  802011:	79 19                	jns    80202c <spawn+0x2a4>
		goto error;

	return 0;

error:
	sys_page_unmap(0, UTEMP);
  802013:	c7 44 24 04 00 00 40 	movl   $0x400000,0x4(%esp)
  80201a:	00 
  80201b:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802022:	e8 63 f2 ff ff       	call   80128a <sys_page_unmap>
  802027:	e9 6b 03 00 00       	jmp    802397 <spawn+0x60f>

	if ((r = init_stack(child, argv, &child_tf.tf_esp)) < 0)
		return r;

	// Set up program segments as defined in ELF header.
	ph = (struct Proghdr*) (elf_buf + elf->e_phoff);
  80202c:	8b 85 04 fe ff ff    	mov    -0x1fc(%ebp),%eax
	for (i = 0; i < elf->e_phnum; i++, ph++) {
  802032:	66 83 bd 14 fe ff ff 	cmpw   $0x0,-0x1ec(%ebp)
  802039:	00 
  80203a:	0f 84 e4 01 00 00    	je     802224 <spawn+0x49c>

	if ((r = init_stack(child, argv, &child_tf.tf_esp)) < 0)
		return r;

	// Set up program segments as defined in ELF header.
	ph = (struct Proghdr*) (elf_buf + elf->e_phoff);
  802040:	8d 84 05 e8 fd ff ff 	lea    -0x218(%ebp,%eax,1),%eax
  802047:	89 85 80 fd ff ff    	mov    %eax,-0x280(%ebp)
  80204d:	c7 85 7c fd ff ff 00 	movl   $0x0,-0x284(%ebp)
  802054:	00 00 00 
	for (i = 0; i < elf->e_phnum; i++, ph++) {
		if (ph->p_type != ELF_PROG_LOAD)
  802057:	8b 95 80 fd ff ff    	mov    -0x280(%ebp),%edx
  80205d:	83 3a 01             	cmpl   $0x1,(%edx)
  802060:	0f 85 9c 01 00 00    	jne    802202 <spawn+0x47a>
			continue;
		perm = PTE_P | PTE_U;
		if (ph->p_flags & ELF_PROG_FLAG_WRITE)
  802066:	8b 42 18             	mov    0x18(%edx),%eax
  802069:	83 e0 02             	and    $0x2,%eax
  80206c:	83 f8 01             	cmp    $0x1,%eax
  80206f:	19 c0                	sbb    %eax,%eax
  802071:	83 e0 fe             	and    $0xfffffffe,%eax
  802074:	83 c0 07             	add    $0x7,%eax
  802077:	89 85 94 fd ff ff    	mov    %eax,-0x26c(%ebp)
			perm |= PTE_W;
		if ((r = map_segment(child, ph->p_va, ph->p_memsz, 
  80207d:	8b 52 04             	mov    0x4(%edx),%edx
  802080:	89 95 78 fd ff ff    	mov    %edx,-0x288(%ebp)
  802086:	8b 85 80 fd ff ff    	mov    -0x280(%ebp),%eax
  80208c:	8b 58 10             	mov    0x10(%eax),%ebx
  80208f:	8b 50 14             	mov    0x14(%eax),%edx
  802092:	89 95 8c fd ff ff    	mov    %edx,-0x274(%ebp)
  802098:	8b 40 08             	mov    0x8(%eax),%eax
  80209b:	89 85 90 fd ff ff    	mov    %eax,-0x270(%ebp)
	int i, r;
	void *blk;

	//cprintf("map_segment %x+%x\n", va, memsz);

	if ((i = PGOFF(va))) {
  8020a1:	25 ff 0f 00 00       	and    $0xfff,%eax
  8020a6:	74 16                	je     8020be <spawn+0x336>
		va -= i;
  8020a8:	29 85 90 fd ff ff    	sub    %eax,-0x270(%ebp)
		memsz += i;
  8020ae:	01 c2                	add    %eax,%edx
  8020b0:	89 95 8c fd ff ff    	mov    %edx,-0x274(%ebp)
		filesz += i;
  8020b6:	01 c3                	add    %eax,%ebx
		fileoffset -= i;
  8020b8:	29 85 78 fd ff ff    	sub    %eax,-0x288(%ebp)
	}

	for (i = 0; i < memsz; i += PGSIZE) {
  8020be:	83 bd 8c fd ff ff 00 	cmpl   $0x0,-0x274(%ebp)
  8020c5:	0f 84 37 01 00 00    	je     802202 <spawn+0x47a>
  8020cb:	bf 00 00 00 00       	mov    $0x0,%edi
  8020d0:	be 00 00 00 00       	mov    $0x0,%esi
		if (i >= filesz) {
  8020d5:	39 fb                	cmp    %edi,%ebx
  8020d7:	77 31                	ja     80210a <spawn+0x382>
			// allocate a blank page
			if ((r = sys_page_alloc(child, (void*) (va + i), perm)) < 0)
  8020d9:	8b 95 94 fd ff ff    	mov    -0x26c(%ebp),%edx
  8020df:	89 54 24 08          	mov    %edx,0x8(%esp)
  8020e3:	03 bd 90 fd ff ff    	add    -0x270(%ebp),%edi
  8020e9:	89 7c 24 04          	mov    %edi,0x4(%esp)
  8020ed:	8b 85 84 fd ff ff    	mov    -0x27c(%ebp),%eax
  8020f3:	89 04 24             	mov    %eax,(%esp)
  8020f6:	e8 4b f2 ff ff       	call   801346 <sys_page_alloc>
  8020fb:	85 c0                	test   %eax,%eax
  8020fd:	0f 89 eb 00 00 00    	jns    8021ee <spawn+0x466>
  802103:	89 c3                	mov    %eax,%ebx
  802105:	e9 69 02 00 00       	jmp    802373 <spawn+0x5eb>
				return r;
		} else {
			// from file
			if ((r = sys_page_alloc(0, UTEMP, PTE_P|PTE_U|PTE_W)) < 0)
  80210a:	c7 44 24 08 07 00 00 	movl   $0x7,0x8(%esp)
  802111:	00 
  802112:	c7 44 24 04 00 00 40 	movl   $0x400000,0x4(%esp)
  802119:	00 
  80211a:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802121:	e8 20 f2 ff ff       	call   801346 <sys_page_alloc>
  802126:	85 c0                	test   %eax,%eax
  802128:	0f 88 3b 02 00 00    	js     802369 <spawn+0x5e1>
				return r;
			if ((r = seek(fd, fileoffset + i)) < 0)
  80212e:	8b 85 78 fd ff ff    	mov    -0x288(%ebp),%eax
  802134:	8d 04 06             	lea    (%esi,%eax,1),%eax
  802137:	89 44 24 04          	mov    %eax,0x4(%esp)
  80213b:	8b 95 88 fd ff ff    	mov    -0x278(%ebp),%edx
  802141:	89 14 24             	mov    %edx,(%esp)
  802144:	e8 0c f4 ff ff       	call   801555 <seek>
  802149:	85 c0                	test   %eax,%eax
  80214b:	0f 88 1c 02 00 00    	js     80236d <spawn+0x5e5>
				return r;
			if ((r = read(fd, UTEMP, MIN(PGSIZE, filesz-i))) < 0)
  802151:	89 d8                	mov    %ebx,%eax
  802153:	29 f8                	sub    %edi,%eax
  802155:	3d 00 10 00 00       	cmp    $0x1000,%eax
  80215a:	ba 00 10 00 00       	mov    $0x1000,%edx
  80215f:	0f 47 c2             	cmova  %edx,%eax
  802162:	89 44 24 08          	mov    %eax,0x8(%esp)
  802166:	c7 44 24 04 00 00 40 	movl   $0x400000,0x4(%esp)
  80216d:	00 
  80216e:	8b 85 88 fd ff ff    	mov    -0x278(%ebp),%eax
  802174:	89 04 24             	mov    %eax,(%esp)
  802177:	e8 f7 f5 ff ff       	call   801773 <read>
  80217c:	85 c0                	test   %eax,%eax
  80217e:	0f 88 ed 01 00 00    	js     802371 <spawn+0x5e9>
				return r;
			if ((r = sys_page_map(0, UTEMP, child, (void*) (va + i), perm)) < 0)
  802184:	8b 95 94 fd ff ff    	mov    -0x26c(%ebp),%edx
  80218a:	89 54 24 10          	mov    %edx,0x10(%esp)
  80218e:	03 bd 90 fd ff ff    	add    -0x270(%ebp),%edi
  802194:	89 7c 24 0c          	mov    %edi,0xc(%esp)
  802198:	8b 85 84 fd ff ff    	mov    -0x27c(%ebp),%eax
  80219e:	89 44 24 08          	mov    %eax,0x8(%esp)
  8021a2:	c7 44 24 04 00 00 40 	movl   $0x400000,0x4(%esp)
  8021a9:	00 
  8021aa:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8021b1:	e8 32 f1 ff ff       	call   8012e8 <sys_page_map>
  8021b6:	85 c0                	test   %eax,%eax
  8021b8:	79 20                	jns    8021da <spawn+0x452>
				panic("spawn: sys_page_map data: %e", r);
  8021ba:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8021be:	c7 44 24 08 e3 35 80 	movl   $0x8035e3,0x8(%esp)
  8021c5:	00 
  8021c6:	c7 44 24 04 0c 01 00 	movl   $0x10c,0x4(%esp)
  8021cd:	00 
  8021ce:	c7 04 24 d7 35 80 00 	movl   $0x8035d7,(%esp)
  8021d5:	e8 76 e2 ff ff       	call   800450 <_panic>
			sys_page_unmap(0, UTEMP);
  8021da:	c7 44 24 04 00 00 40 	movl   $0x400000,0x4(%esp)
  8021e1:	00 
  8021e2:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8021e9:	e8 9c f0 ff ff       	call   80128a <sys_page_unmap>
		memsz += i;
		filesz += i;
		fileoffset -= i;
	}

	for (i = 0; i < memsz; i += PGSIZE) {
  8021ee:	81 c6 00 10 00 00    	add    $0x1000,%esi
  8021f4:	89 f7                	mov    %esi,%edi
  8021f6:	39 b5 8c fd ff ff    	cmp    %esi,-0x274(%ebp)
  8021fc:	0f 87 d3 fe ff ff    	ja     8020d5 <spawn+0x34d>
	if ((r = init_stack(child, argv, &child_tf.tf_esp)) < 0)
		return r;

	// Set up program segments as defined in ELF header.
	ph = (struct Proghdr*) (elf_buf + elf->e_phoff);
	for (i = 0; i < elf->e_phnum; i++, ph++) {
  802202:	83 85 7c fd ff ff 01 	addl   $0x1,-0x284(%ebp)
  802209:	0f b7 85 14 fe ff ff 	movzwl -0x1ec(%ebp),%eax
  802210:	3b 85 7c fd ff ff    	cmp    -0x284(%ebp),%eax
  802216:	7e 0c                	jle    802224 <spawn+0x49c>
  802218:	83 85 80 fd ff ff 20 	addl   $0x20,-0x280(%ebp)
  80221f:	e9 33 fe ff ff       	jmp    802057 <spawn+0x2cf>
			perm |= PTE_W;
		if ((r = map_segment(child, ph->p_va, ph->p_memsz, 
				     fd, ph->p_filesz, ph->p_offset, perm)) < 0)
			goto error;
	}
	close(fd);
  802224:	8b 95 88 fd ff ff    	mov    -0x278(%ebp),%edx
  80222a:	89 14 24             	mov    %edx,(%esp)
  80222d:	e8 fa f6 ff ff       	call   80192c <close>
static int
copy_shared_pages(envid_t child)
{
    int va;
    int r=0;
    envid_t cur = sys_getenvid();
  802232:	e8 a2 f1 ff ff       	call   8013d9 <sys_getenvid>
  802237:	89 85 94 fd ff ff    	mov    %eax,-0x26c(%ebp)
  80223d:	b8 00 00 00 00       	mov    $0x0,%eax
  802242:	bb 00 00 00 00       	mov    $0x0,%ebx
    for (va=0;va<USTACKTOP; va+=PGSIZE) {
        if (((vpd[PDX(va)] & PTE_P) && (vpt[VPN(va)] & PTE_P) && (vpt[VPN(va)] & PTE_SHARE))) {
  802247:	be 00 d0 7b ef       	mov    $0xef7bd000,%esi
  80224c:	bf 00 00 40 ef       	mov    $0xef400000,%edi
  802251:	89 c2                	mov    %eax,%edx
  802253:	89 d1                	mov    %edx,%ecx
  802255:	c1 e9 16             	shr    $0x16,%ecx
  802258:	8b 0c 8e             	mov    (%esi,%ecx,4),%ecx
  80225b:	f6 c1 01             	test   $0x1,%cl
  80225e:	74 5f                	je     8022bf <spawn+0x537>
  802260:	c1 ea 0c             	shr    $0xc,%edx
  802263:	8b 0c 97             	mov    (%edi,%edx,4),%ecx
  802266:	f6 c1 01             	test   $0x1,%cl
  802269:	74 54                	je     8022bf <spawn+0x537>
  80226b:	8b 0c 97             	mov    (%edi,%edx,4),%ecx
  80226e:	f6 c5 04             	test   $0x4,%ch
  802271:	74 4c                	je     8022bf <spawn+0x537>
            if((r=sys_page_map(cur, (void *)(va), child, (void *)(va), vpt[VPN(va)]&PTE_USER))<0)
  802273:	8b 04 97             	mov    (%edi,%edx,4),%eax
  802276:	25 07 0e 00 00       	and    $0xe07,%eax
  80227b:	89 44 24 10          	mov    %eax,0x10(%esp)
  80227f:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  802283:	8b 85 84 fd ff ff    	mov    -0x27c(%ebp),%eax
  802289:	89 44 24 08          	mov    %eax,0x8(%esp)
  80228d:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  802291:	8b 95 94 fd ff ff    	mov    -0x26c(%ebp),%edx
  802297:	89 14 24             	mov    %edx,(%esp)
  80229a:	e8 49 f0 ff ff       	call   8012e8 <sys_page_map>
  80229f:	85 c0                	test   %eax,%eax
  8022a1:	79 1c                	jns    8022bf <spawn+0x537>
                panic("copy_shared_pages: error sharing\n");
  8022a3:	c7 44 24 08 70 36 80 	movl   $0x803670,0x8(%esp)
  8022aa:	00 
  8022ab:	c7 44 24 04 1d 01 00 	movl   $0x11d,0x4(%esp)
  8022b2:	00 
  8022b3:	c7 04 24 d7 35 80 00 	movl   $0x8035d7,(%esp)
  8022ba:	e8 91 e1 ff ff       	call   800450 <_panic>
copy_shared_pages(envid_t child)
{
    int va;
    int r=0;
    envid_t cur = sys_getenvid();
    for (va=0;va<USTACKTOP; va+=PGSIZE) {
  8022bf:	81 c3 00 10 00 00    	add    $0x1000,%ebx
  8022c5:	89 da                	mov    %ebx,%edx
  8022c7:	81 fb 00 e0 bf ee    	cmp    $0xeebfe000,%ebx
  8022cd:	75 84                	jne    802253 <spawn+0x4cb>
	}
	close(fd);
	fd = -1;

	// Copy shared library state.
	if ((r = copy_shared_pages(child)) < 0)
  8022cf:	85 c0                	test   %eax,%eax
  8022d1:	79 20                	jns    8022f3 <spawn+0x56b>
		panic("copy_shared_pages: %e", r);
  8022d3:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8022d7:	c7 44 24 08 00 36 80 	movl   $0x803600,0x8(%esp)
  8022de:	00 
  8022df:	c7 44 24 04 82 00 00 	movl   $0x82,0x4(%esp)
  8022e6:	00 
  8022e7:	c7 04 24 d7 35 80 00 	movl   $0x8035d7,(%esp)
  8022ee:	e8 5d e1 ff ff       	call   800450 <_panic>

	if ((r = sys_env_set_trapframe(child, &child_tf)) < 0)
  8022f3:	8d 85 a4 fd ff ff    	lea    -0x25c(%ebp),%eax
  8022f9:	89 44 24 04          	mov    %eax,0x4(%esp)
  8022fd:	8b 85 84 fd ff ff    	mov    -0x27c(%ebp),%eax
  802303:	89 04 24             	mov    %eax,(%esp)
  802306:	e8 c3 ee ff ff       	call   8011ce <sys_env_set_trapframe>
  80230b:	85 c0                	test   %eax,%eax
  80230d:	79 20                	jns    80232f <spawn+0x5a7>
		panic("sys_env_set_trapframe: %e", r);
  80230f:	89 44 24 0c          	mov    %eax,0xc(%esp)
  802313:	c7 44 24 08 16 36 80 	movl   $0x803616,0x8(%esp)
  80231a:	00 
  80231b:	c7 44 24 04 85 00 00 	movl   $0x85,0x4(%esp)
  802322:	00 
  802323:	c7 04 24 d7 35 80 00 	movl   $0x8035d7,(%esp)
  80232a:	e8 21 e1 ff ff       	call   800450 <_panic>

	if ((r = sys_env_set_status(child, ENV_RUNNABLE)) < 0)
  80232f:	c7 44 24 04 01 00 00 	movl   $0x1,0x4(%esp)
  802336:	00 
  802337:	8b 95 84 fd ff ff    	mov    -0x27c(%ebp),%edx
  80233d:	89 14 24             	mov    %edx,(%esp)
  802340:	e8 e7 ee ff ff       	call   80122c <sys_env_set_status>
  802345:	85 c0                	test   %eax,%eax
  802347:	79 48                	jns    802391 <spawn+0x609>
		panic("sys_env_set_status: %e", r);
  802349:	89 44 24 0c          	mov    %eax,0xc(%esp)
  80234d:	c7 44 24 08 30 36 80 	movl   $0x803630,0x8(%esp)
  802354:	00 
  802355:	c7 44 24 04 88 00 00 	movl   $0x88,0x4(%esp)
  80235c:	00 
  80235d:	c7 04 24 d7 35 80 00 	movl   $0x8035d7,(%esp)
  802364:	e8 e7 e0 ff ff       	call   800450 <_panic>
  802369:	89 c3                	mov    %eax,%ebx
  80236b:	eb 06                	jmp    802373 <spawn+0x5eb>
  80236d:	89 c3                	mov    %eax,%ebx
  80236f:	eb 02                	jmp    802373 <spawn+0x5eb>
  802371:	89 c3                	mov    %eax,%ebx

	return child;

error:
	sys_env_destroy(child);
  802373:	8b 85 84 fd ff ff    	mov    -0x27c(%ebp),%eax
  802379:	89 04 24             	mov    %eax,(%esp)
  80237c:	e8 8c f0 ff ff       	call   80140d <sys_env_destroy>
	close(fd);
  802381:	8b 95 88 fd ff ff    	mov    -0x278(%ebp),%edx
  802387:	89 14 24             	mov    %edx,(%esp)
  80238a:	e8 9d f5 ff ff       	call   80192c <close>
	return r;
  80238f:	eb 06                	jmp    802397 <spawn+0x60f>
  802391:	8b 9d 84 fd ff ff    	mov    -0x27c(%ebp),%ebx
}
  802397:	89 d8                	mov    %ebx,%eax
  802399:	81 c4 9c 02 00 00    	add    $0x29c,%esp
  80239f:	5b                   	pop    %ebx
  8023a0:	5e                   	pop    %esi
  8023a1:	5f                   	pop    %edi
  8023a2:	5d                   	pop    %ebp
  8023a3:	c3                   	ret    

008023a4 <spawnl>:

// Spawn, taking command-line arguments array directly on the stack.
int
spawnl(const char *prog, const char *arg0, ...)
{
  8023a4:	55                   	push   %ebp
  8023a5:	89 e5                	mov    %esp,%ebp
  8023a7:	83 ec 18             	sub    $0x18,%esp
	return spawn(prog, &arg0);
  8023aa:	8d 45 0c             	lea    0xc(%ebp),%eax
  8023ad:	89 44 24 04          	mov    %eax,0x4(%esp)
  8023b1:	8b 45 08             	mov    0x8(%ebp),%eax
  8023b4:	89 04 24             	mov    %eax,(%esp)
  8023b7:	e8 cc f9 ff ff       	call   801d88 <spawn>
}
  8023bc:	c9                   	leave  
  8023bd:	c3                   	ret    
	...

008023c0 <devsock_stat>:
	return nsipc_send(fd->fd_sock.sockid, buf, n, 0);
}

static int
devsock_stat(struct Fd *fd, struct Stat *stat)
{
  8023c0:	55                   	push   %ebp
  8023c1:	89 e5                	mov    %esp,%ebp
  8023c3:	83 ec 18             	sub    $0x18,%esp
	strcpy(stat->st_name, "<sock>");
  8023c6:	c7 44 24 04 92 36 80 	movl   $0x803692,0x4(%esp)
  8023cd:	00 
  8023ce:	8b 45 0c             	mov    0xc(%ebp),%eax
  8023d1:	89 04 24             	mov    %eax,(%esp)
  8023d4:	e8 11 e8 ff ff       	call   800bea <strcpy>
	return 0;
}
  8023d9:	b8 00 00 00 00       	mov    $0x0,%eax
  8023de:	c9                   	leave  
  8023df:	c3                   	ret    

008023e0 <devsock_close>:
	return nsipc_shutdown(r, how);
}

static int
devsock_close(struct Fd *fd)
{
  8023e0:	55                   	push   %ebp
  8023e1:	89 e5                	mov    %esp,%ebp
  8023e3:	83 ec 18             	sub    $0x18,%esp
	return nsipc_close(fd->fd_sock.sockid);
  8023e6:	8b 45 08             	mov    0x8(%ebp),%eax
  8023e9:	8b 40 0c             	mov    0xc(%eax),%eax
  8023ec:	89 04 24             	mov    %eax,(%esp)
  8023ef:	e8 9d 02 00 00       	call   802691 <nsipc_close>
}
  8023f4:	c9                   	leave  
  8023f5:	c3                   	ret    

008023f6 <devsock_write>:
	return nsipc_recv(fd->fd_sock.sockid, buf, n, 0);
}

static ssize_t
devsock_write(struct Fd *fd, const void *buf, size_t n)
{
  8023f6:	55                   	push   %ebp
  8023f7:	89 e5                	mov    %esp,%ebp
  8023f9:	83 ec 18             	sub    $0x18,%esp
	return nsipc_send(fd->fd_sock.sockid, buf, n, 0);
  8023fc:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  802403:	00 
  802404:	8b 45 10             	mov    0x10(%ebp),%eax
  802407:	89 44 24 08          	mov    %eax,0x8(%esp)
  80240b:	8b 45 0c             	mov    0xc(%ebp),%eax
  80240e:	89 44 24 04          	mov    %eax,0x4(%esp)
  802412:	8b 45 08             	mov    0x8(%ebp),%eax
  802415:	8b 40 0c             	mov    0xc(%eax),%eax
  802418:	89 04 24             	mov    %eax,(%esp)
  80241b:	e8 ad 02 00 00       	call   8026cd <nsipc_send>
}
  802420:	c9                   	leave  
  802421:	c3                   	ret    

00802422 <devsock_read>:
	return nsipc_listen(r, backlog);
}

static ssize_t
devsock_read(struct Fd *fd, void *buf, size_t n)
{
  802422:	55                   	push   %ebp
  802423:	89 e5                	mov    %esp,%ebp
  802425:	83 ec 18             	sub    $0x18,%esp
	return nsipc_recv(fd->fd_sock.sockid, buf, n, 0);
  802428:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  80242f:	00 
  802430:	8b 45 10             	mov    0x10(%ebp),%eax
  802433:	89 44 24 08          	mov    %eax,0x8(%esp)
  802437:	8b 45 0c             	mov    0xc(%ebp),%eax
  80243a:	89 44 24 04          	mov    %eax,0x4(%esp)
  80243e:	8b 45 08             	mov    0x8(%ebp),%eax
  802441:	8b 40 0c             	mov    0xc(%eax),%eax
  802444:	89 04 24             	mov    %eax,(%esp)
  802447:	e8 f4 02 00 00       	call   802740 <nsipc_recv>
}
  80244c:	c9                   	leave  
  80244d:	c3                   	ret    

0080244e <alloc_sockfd>:
	return sfd->fd_sock.sockid;
}

static int
alloc_sockfd(int sockid)
{
  80244e:	55                   	push   %ebp
  80244f:	89 e5                	mov    %esp,%ebp
  802451:	56                   	push   %esi
  802452:	53                   	push   %ebx
  802453:	83 ec 20             	sub    $0x20,%esp
  802456:	89 c6                	mov    %eax,%esi
	struct Fd *sfd;
	int r;

	if ((r = fd_alloc(&sfd)) < 0
  802458:	8d 45 f4             	lea    -0xc(%ebp),%eax
  80245b:	89 04 24             	mov    %eax,(%esp)
  80245e:	e8 38 f0 ff ff       	call   80149b <fd_alloc>
  802463:	89 c3                	mov    %eax,%ebx
  802465:	85 c0                	test   %eax,%eax
  802467:	78 21                	js     80248a <alloc_sockfd+0x3c>
	    || (r = sys_page_alloc(0, sfd, PTE_P|PTE_W|PTE_U)) < 0) {
  802469:	c7 44 24 08 07 00 00 	movl   $0x7,0x8(%esp)
  802470:	00 
  802471:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802474:	89 44 24 04          	mov    %eax,0x4(%esp)
  802478:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  80247f:	e8 c2 ee ff ff       	call   801346 <sys_page_alloc>
  802484:	89 c3                	mov    %eax,%ebx
alloc_sockfd(int sockid)
{
	struct Fd *sfd;
	int r;

	if ((r = fd_alloc(&sfd)) < 0
  802486:	85 c0                	test   %eax,%eax
  802488:	79 0a                	jns    802494 <alloc_sockfd+0x46>
	    || (r = sys_page_alloc(0, sfd, PTE_P|PTE_W|PTE_U)) < 0) {
		nsipc_close(sockid);
  80248a:	89 34 24             	mov    %esi,(%esp)
  80248d:	e8 ff 01 00 00       	call   802691 <nsipc_close>
		return r;
  802492:	eb 28                	jmp    8024bc <alloc_sockfd+0x6e>
	}

	sfd->fd_dev_id = devsock.dev_id;
  802494:	8b 15 ac 87 80 00    	mov    0x8087ac,%edx
  80249a:	8b 45 f4             	mov    -0xc(%ebp),%eax
  80249d:	89 10                	mov    %edx,(%eax)
	sfd->fd_omode = O_RDWR;
  80249f:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8024a2:	c7 40 08 02 00 00 00 	movl   $0x2,0x8(%eax)
	sfd->fd_sock.sockid = sockid;
  8024a9:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8024ac:	89 70 0c             	mov    %esi,0xc(%eax)
	return fd2num(sfd);
  8024af:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8024b2:	89 04 24             	mov    %eax,(%esp)
  8024b5:	e8 b6 ef ff ff       	call   801470 <fd2num>
  8024ba:	89 c3                	mov    %eax,%ebx
}
  8024bc:	89 d8                	mov    %ebx,%eax
  8024be:	83 c4 20             	add    $0x20,%esp
  8024c1:	5b                   	pop    %ebx
  8024c2:	5e                   	pop    %esi
  8024c3:	5d                   	pop    %ebp
  8024c4:	c3                   	ret    

008024c5 <socket>:
	return 0;
}

int
socket(int domain, int type, int protocol)
{
  8024c5:	55                   	push   %ebp
  8024c6:	89 e5                	mov    %esp,%ebp
  8024c8:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = nsipc_socket(domain, type, protocol)) < 0)
  8024cb:	8b 45 10             	mov    0x10(%ebp),%eax
  8024ce:	89 44 24 08          	mov    %eax,0x8(%esp)
  8024d2:	8b 45 0c             	mov    0xc(%ebp),%eax
  8024d5:	89 44 24 04          	mov    %eax,0x4(%esp)
  8024d9:	8b 45 08             	mov    0x8(%ebp),%eax
  8024dc:	89 04 24             	mov    %eax,(%esp)
  8024df:	e8 61 01 00 00       	call   802645 <nsipc_socket>
  8024e4:	85 c0                	test   %eax,%eax
  8024e6:	78 05                	js     8024ed <socket+0x28>
		return r;
	return alloc_sockfd(r);
  8024e8:	e8 61 ff ff ff       	call   80244e <alloc_sockfd>
}
  8024ed:	c9                   	leave  
  8024ee:	66 90                	xchg   %ax,%ax
  8024f0:	c3                   	ret    

008024f1 <fd2sockid>:
	.dev_stat =	devsock_stat,
};

static int
fd2sockid(int fd)
{
  8024f1:	55                   	push   %ebp
  8024f2:	89 e5                	mov    %esp,%ebp
  8024f4:	83 ec 28             	sub    $0x28,%esp
	struct Fd *sfd;
	int r;

	if ((r = fd_lookup(fd, &sfd)) < 0)
  8024f7:	8d 55 f4             	lea    -0xc(%ebp),%edx
  8024fa:	89 54 24 04          	mov    %edx,0x4(%esp)
  8024fe:	89 04 24             	mov    %eax,(%esp)
  802501:	e8 07 f0 ff ff       	call   80150d <fd_lookup>
  802506:	85 c0                	test   %eax,%eax
  802508:	78 15                	js     80251f <fd2sockid+0x2e>
		return r;
	if (sfd->fd_dev_id != devsock.dev_id)
  80250a:	8b 55 f4             	mov    -0xc(%ebp),%edx
  80250d:	8b 0a                	mov    (%edx),%ecx
  80250f:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  802514:	3b 0d ac 87 80 00    	cmp    0x8087ac,%ecx
  80251a:	75 03                	jne    80251f <fd2sockid+0x2e>
		return -E_NOT_SUPP;
	return sfd->fd_sock.sockid;
  80251c:	8b 42 0c             	mov    0xc(%edx),%eax
}
  80251f:	c9                   	leave  
  802520:	c3                   	ret    

00802521 <listen>:
	return nsipc_connect(r, name, namelen);
}

int
listen(int s, int backlog)
{
  802521:	55                   	push   %ebp
  802522:	89 e5                	mov    %esp,%ebp
  802524:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  802527:	8b 45 08             	mov    0x8(%ebp),%eax
  80252a:	e8 c2 ff ff ff       	call   8024f1 <fd2sockid>
  80252f:	85 c0                	test   %eax,%eax
  802531:	78 0f                	js     802542 <listen+0x21>
		return r;
	return nsipc_listen(r, backlog);
  802533:	8b 55 0c             	mov    0xc(%ebp),%edx
  802536:	89 54 24 04          	mov    %edx,0x4(%esp)
  80253a:	89 04 24             	mov    %eax,(%esp)
  80253d:	e8 2d 01 00 00       	call   80266f <nsipc_listen>
}
  802542:	c9                   	leave  
  802543:	c3                   	ret    

00802544 <connect>:
	return nsipc_close(fd->fd_sock.sockid);
}

int
connect(int s, const struct sockaddr *name, socklen_t namelen)
{
  802544:	55                   	push   %ebp
  802545:	89 e5                	mov    %esp,%ebp
  802547:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  80254a:	8b 45 08             	mov    0x8(%ebp),%eax
  80254d:	e8 9f ff ff ff       	call   8024f1 <fd2sockid>
  802552:	85 c0                	test   %eax,%eax
  802554:	78 16                	js     80256c <connect+0x28>
		return r;
	return nsipc_connect(r, name, namelen);
  802556:	8b 55 10             	mov    0x10(%ebp),%edx
  802559:	89 54 24 08          	mov    %edx,0x8(%esp)
  80255d:	8b 55 0c             	mov    0xc(%ebp),%edx
  802560:	89 54 24 04          	mov    %edx,0x4(%esp)
  802564:	89 04 24             	mov    %eax,(%esp)
  802567:	e8 54 02 00 00       	call   8027c0 <nsipc_connect>
}
  80256c:	c9                   	leave  
  80256d:	c3                   	ret    

0080256e <shutdown>:
	return nsipc_bind(r, name, namelen);
}

int
shutdown(int s, int how)
{
  80256e:	55                   	push   %ebp
  80256f:	89 e5                	mov    %esp,%ebp
  802571:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  802574:	8b 45 08             	mov    0x8(%ebp),%eax
  802577:	e8 75 ff ff ff       	call   8024f1 <fd2sockid>
  80257c:	85 c0                	test   %eax,%eax
  80257e:	78 0f                	js     80258f <shutdown+0x21>
		return r;
	return nsipc_shutdown(r, how);
  802580:	8b 55 0c             	mov    0xc(%ebp),%edx
  802583:	89 54 24 04          	mov    %edx,0x4(%esp)
  802587:	89 04 24             	mov    %eax,(%esp)
  80258a:	e8 1c 01 00 00       	call   8026ab <nsipc_shutdown>
}
  80258f:	c9                   	leave  
  802590:	c3                   	ret    

00802591 <bind>:
	return alloc_sockfd(r);
}

int
bind(int s, struct sockaddr *name, socklen_t namelen)
{
  802591:	55                   	push   %ebp
  802592:	89 e5                	mov    %esp,%ebp
  802594:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  802597:	8b 45 08             	mov    0x8(%ebp),%eax
  80259a:	e8 52 ff ff ff       	call   8024f1 <fd2sockid>
  80259f:	85 c0                	test   %eax,%eax
  8025a1:	78 16                	js     8025b9 <bind+0x28>
		return r;
	return nsipc_bind(r, name, namelen);
  8025a3:	8b 55 10             	mov    0x10(%ebp),%edx
  8025a6:	89 54 24 08          	mov    %edx,0x8(%esp)
  8025aa:	8b 55 0c             	mov    0xc(%ebp),%edx
  8025ad:	89 54 24 04          	mov    %edx,0x4(%esp)
  8025b1:	89 04 24             	mov    %eax,(%esp)
  8025b4:	e8 46 02 00 00       	call   8027ff <nsipc_bind>
}
  8025b9:	c9                   	leave  
  8025ba:	c3                   	ret    

008025bb <accept>:
	return fd2num(sfd);
}

int
accept(int s, struct sockaddr *addr, socklen_t *addrlen)
{
  8025bb:	55                   	push   %ebp
  8025bc:	89 e5                	mov    %esp,%ebp
  8025be:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  8025c1:	8b 45 08             	mov    0x8(%ebp),%eax
  8025c4:	e8 28 ff ff ff       	call   8024f1 <fd2sockid>
  8025c9:	85 c0                	test   %eax,%eax
  8025cb:	78 1f                	js     8025ec <accept+0x31>
		return r;
	if ((r = nsipc_accept(r, addr, addrlen)) < 0)
  8025cd:	8b 55 10             	mov    0x10(%ebp),%edx
  8025d0:	89 54 24 08          	mov    %edx,0x8(%esp)
  8025d4:	8b 55 0c             	mov    0xc(%ebp),%edx
  8025d7:	89 54 24 04          	mov    %edx,0x4(%esp)
  8025db:	89 04 24             	mov    %eax,(%esp)
  8025de:	e8 5b 02 00 00       	call   80283e <nsipc_accept>
  8025e3:	85 c0                	test   %eax,%eax
  8025e5:	78 05                	js     8025ec <accept+0x31>
		return r;
	return alloc_sockfd(r);
  8025e7:	e8 62 fe ff ff       	call   80244e <alloc_sockfd>
}
  8025ec:	c9                   	leave  
  8025ed:	8d 76 00             	lea    0x0(%esi),%esi
  8025f0:	c3                   	ret    
	...

00802600 <nsipc>:
// may be written back to nsipcbuf.
// type: request code, passed as the simple integer IPC value.
// Returns 0 if successful, < 0 on failure.
static int
nsipc(unsigned type)
{
  802600:	55                   	push   %ebp
  802601:	89 e5                	mov    %esp,%ebp
  802603:	83 ec 28             	sub    $0x28,%esp
    int r=0;
    envid_t from;
	if (debug)
		cprintf("[%08x] nsipc %d\n", env->env_id, type);

	ipc_send(envs[2].env_id, type, &nsipcbuf, PTE_P|PTE_W|PTE_U);
  802606:	8b 15 44 01 c0 ee    	mov    0xeec00144,%edx
  80260c:	c7 44 24 0c 07 00 00 	movl   $0x7,0xc(%esp)
  802613:	00 
  802614:	c7 44 24 08 00 60 80 	movl   $0x806000,0x8(%esp)
  80261b:	00 
  80261c:	89 44 24 04          	mov    %eax,0x4(%esp)
  802620:	89 14 24             	mov    %edx,(%esp)
  802623:	e8 b8 06 00 00       	call   802ce0 <ipc_send>
	r=ipc_recv(&from, NULL, NULL);
  802628:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  80262f:	00 
  802630:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  802637:	00 
  802638:	8d 45 f4             	lea    -0xc(%ebp),%eax
  80263b:	89 04 24             	mov    %eax,(%esp)
  80263e:	e8 0f 07 00 00       	call   802d52 <ipc_recv>
    return r;
}
  802643:	c9                   	leave  
  802644:	c3                   	ret    

00802645 <nsipc_socket>:
	return nsipc(NSREQ_SEND);
}

int
nsipc_socket(int domain, int type, int protocol)
{
  802645:	55                   	push   %ebp
  802646:	89 e5                	mov    %esp,%ebp
  802648:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.socket.req_domain = domain;
  80264b:	8b 45 08             	mov    0x8(%ebp),%eax
  80264e:	a3 00 60 80 00       	mov    %eax,0x806000
	nsipcbuf.socket.req_type = type;
  802653:	8b 45 0c             	mov    0xc(%ebp),%eax
  802656:	a3 04 60 80 00       	mov    %eax,0x806004
	nsipcbuf.socket.req_protocol = protocol;
  80265b:	8b 45 10             	mov    0x10(%ebp),%eax
  80265e:	a3 08 60 80 00       	mov    %eax,0x806008
	return nsipc(NSREQ_SOCKET);
  802663:	b8 09 00 00 00       	mov    $0x9,%eax
  802668:	e8 93 ff ff ff       	call   802600 <nsipc>
}
  80266d:	c9                   	leave  
  80266e:	c3                   	ret    

0080266f <nsipc_listen>:
	return nsipc(NSREQ_CONNECT);
}

int
nsipc_listen(int s, int backlog)
{
  80266f:	55                   	push   %ebp
  802670:	89 e5                	mov    %esp,%ebp
  802672:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.listen.req_s = s;
  802675:	8b 45 08             	mov    0x8(%ebp),%eax
  802678:	a3 00 60 80 00       	mov    %eax,0x806000
	nsipcbuf.listen.req_backlog = backlog;
  80267d:	8b 45 0c             	mov    0xc(%ebp),%eax
  802680:	a3 04 60 80 00       	mov    %eax,0x806004
	return nsipc(NSREQ_LISTEN);
  802685:	b8 06 00 00 00       	mov    $0x6,%eax
  80268a:	e8 71 ff ff ff       	call   802600 <nsipc>
}
  80268f:	c9                   	leave  
  802690:	c3                   	ret    

00802691 <nsipc_close>:
	return nsipc(NSREQ_SHUTDOWN);
}

int
nsipc_close(int s)
{
  802691:	55                   	push   %ebp
  802692:	89 e5                	mov    %esp,%ebp
  802694:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.close.req_s = s;
  802697:	8b 45 08             	mov    0x8(%ebp),%eax
  80269a:	a3 00 60 80 00       	mov    %eax,0x806000
	return nsipc(NSREQ_CLOSE);
  80269f:	b8 04 00 00 00       	mov    $0x4,%eax
  8026a4:	e8 57 ff ff ff       	call   802600 <nsipc>
}
  8026a9:	c9                   	leave  
  8026aa:	c3                   	ret    

008026ab <nsipc_shutdown>:
	return nsipc(NSREQ_BIND);
}

int
nsipc_shutdown(int s, int how)
{
  8026ab:	55                   	push   %ebp
  8026ac:	89 e5                	mov    %esp,%ebp
  8026ae:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.shutdown.req_s = s;
  8026b1:	8b 45 08             	mov    0x8(%ebp),%eax
  8026b4:	a3 00 60 80 00       	mov    %eax,0x806000
	nsipcbuf.shutdown.req_how = how;
  8026b9:	8b 45 0c             	mov    0xc(%ebp),%eax
  8026bc:	a3 04 60 80 00       	mov    %eax,0x806004
	return nsipc(NSREQ_SHUTDOWN);
  8026c1:	b8 03 00 00 00       	mov    $0x3,%eax
  8026c6:	e8 35 ff ff ff       	call   802600 <nsipc>
}
  8026cb:	c9                   	leave  
  8026cc:	c3                   	ret    

008026cd <nsipc_send>:
	return r;
}

int
nsipc_send(int s, const void *buf, int size, unsigned int flags)
{
  8026cd:	55                   	push   %ebp
  8026ce:	89 e5                	mov    %esp,%ebp
  8026d0:	53                   	push   %ebx
  8026d1:	83 ec 14             	sub    $0x14,%esp
  8026d4:	8b 5d 10             	mov    0x10(%ebp),%ebx
	nsipcbuf.send.req_s = s;
  8026d7:	8b 45 08             	mov    0x8(%ebp),%eax
  8026da:	a3 00 60 80 00       	mov    %eax,0x806000
	assert(size < 1600);
  8026df:	81 fb 3f 06 00 00    	cmp    $0x63f,%ebx
  8026e5:	7e 24                	jle    80270b <nsipc_send+0x3e>
  8026e7:	c7 44 24 0c 9e 36 80 	movl   $0x80369e,0xc(%esp)
  8026ee:	00 
  8026ef:	c7 44 24 08 c2 35 80 	movl   $0x8035c2,0x8(%esp)
  8026f6:	00 
  8026f7:	c7 44 24 04 69 00 00 	movl   $0x69,0x4(%esp)
  8026fe:	00 
  8026ff:	c7 04 24 aa 36 80 00 	movl   $0x8036aa,(%esp)
  802706:	e8 45 dd ff ff       	call   800450 <_panic>
	memmove(&nsipcbuf.send.req_buf, buf, size);
  80270b:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  80270f:	8b 45 0c             	mov    0xc(%ebp),%eax
  802712:	89 44 24 04          	mov    %eax,0x4(%esp)
  802716:	c7 04 24 0c 60 80 00 	movl   $0x80600c,(%esp)
  80271d:	e8 83 e6 ff ff       	call   800da5 <memmove>
	nsipcbuf.send.req_size = size;
  802722:	89 1d 04 60 80 00    	mov    %ebx,0x806004
	nsipcbuf.send.req_flags = flags;
  802728:	8b 45 14             	mov    0x14(%ebp),%eax
  80272b:	a3 08 60 80 00       	mov    %eax,0x806008
	return nsipc(NSREQ_SEND);
  802730:	b8 08 00 00 00       	mov    $0x8,%eax
  802735:	e8 c6 fe ff ff       	call   802600 <nsipc>
}
  80273a:	83 c4 14             	add    $0x14,%esp
  80273d:	5b                   	pop    %ebx
  80273e:	5d                   	pop    %ebp
  80273f:	c3                   	ret    

00802740 <nsipc_recv>:
	return nsipc(NSREQ_LISTEN);
}

int
nsipc_recv(int s, void *mem, int len, unsigned int flags)
{
  802740:	55                   	push   %ebp
  802741:	89 e5                	mov    %esp,%ebp
  802743:	56                   	push   %esi
  802744:	53                   	push   %ebx
  802745:	83 ec 10             	sub    $0x10,%esp
  802748:	8b 75 10             	mov    0x10(%ebp),%esi
	int r;

	nsipcbuf.recv.req_s = s;
  80274b:	8b 45 08             	mov    0x8(%ebp),%eax
  80274e:	a3 00 60 80 00       	mov    %eax,0x806000
	nsipcbuf.recv.req_len = len;
  802753:	89 35 04 60 80 00    	mov    %esi,0x806004
	nsipcbuf.recv.req_flags = flags;
  802759:	8b 45 14             	mov    0x14(%ebp),%eax
  80275c:	a3 08 60 80 00       	mov    %eax,0x806008

	if ((r = nsipc(NSREQ_RECV)) >= 0) {
  802761:	b8 07 00 00 00       	mov    $0x7,%eax
  802766:	e8 95 fe ff ff       	call   802600 <nsipc>
  80276b:	89 c3                	mov    %eax,%ebx
  80276d:	85 c0                	test   %eax,%eax
  80276f:	78 46                	js     8027b7 <nsipc_recv+0x77>
		assert(r < 1600 && r <= len);
  802771:	3d 3f 06 00 00       	cmp    $0x63f,%eax
  802776:	7f 04                	jg     80277c <nsipc_recv+0x3c>
  802778:	39 c6                	cmp    %eax,%esi
  80277a:	7d 24                	jge    8027a0 <nsipc_recv+0x60>
  80277c:	c7 44 24 0c b6 36 80 	movl   $0x8036b6,0xc(%esp)
  802783:	00 
  802784:	c7 44 24 08 c2 35 80 	movl   $0x8035c2,0x8(%esp)
  80278b:	00 
  80278c:	c7 44 24 04 5e 00 00 	movl   $0x5e,0x4(%esp)
  802793:	00 
  802794:	c7 04 24 aa 36 80 00 	movl   $0x8036aa,(%esp)
  80279b:	e8 b0 dc ff ff       	call   800450 <_panic>
		memmove(mem, nsipcbuf.recvRet.ret_buf, r);
  8027a0:	89 44 24 08          	mov    %eax,0x8(%esp)
  8027a4:	c7 44 24 04 00 60 80 	movl   $0x806000,0x4(%esp)
  8027ab:	00 
  8027ac:	8b 45 0c             	mov    0xc(%ebp),%eax
  8027af:	89 04 24             	mov    %eax,(%esp)
  8027b2:	e8 ee e5 ff ff       	call   800da5 <memmove>
	}

	return r;
}
  8027b7:	89 d8                	mov    %ebx,%eax
  8027b9:	83 c4 10             	add    $0x10,%esp
  8027bc:	5b                   	pop    %ebx
  8027bd:	5e                   	pop    %esi
  8027be:	5d                   	pop    %ebp
  8027bf:	c3                   	ret    

008027c0 <nsipc_connect>:
	return nsipc(NSREQ_CLOSE);
}

int
nsipc_connect(int s, const struct sockaddr *name, socklen_t namelen)
{
  8027c0:	55                   	push   %ebp
  8027c1:	89 e5                	mov    %esp,%ebp
  8027c3:	53                   	push   %ebx
  8027c4:	83 ec 14             	sub    $0x14,%esp
  8027c7:	8b 5d 10             	mov    0x10(%ebp),%ebx
	nsipcbuf.connect.req_s = s;
  8027ca:	8b 45 08             	mov    0x8(%ebp),%eax
  8027cd:	a3 00 60 80 00       	mov    %eax,0x806000
	memmove(&nsipcbuf.connect.req_name, name, namelen);
  8027d2:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  8027d6:	8b 45 0c             	mov    0xc(%ebp),%eax
  8027d9:	89 44 24 04          	mov    %eax,0x4(%esp)
  8027dd:	c7 04 24 04 60 80 00 	movl   $0x806004,(%esp)
  8027e4:	e8 bc e5 ff ff       	call   800da5 <memmove>
	nsipcbuf.connect.req_namelen = namelen;
  8027e9:	89 1d 14 60 80 00    	mov    %ebx,0x806014
	return nsipc(NSREQ_CONNECT);
  8027ef:	b8 05 00 00 00       	mov    $0x5,%eax
  8027f4:	e8 07 fe ff ff       	call   802600 <nsipc>
}
  8027f9:	83 c4 14             	add    $0x14,%esp
  8027fc:	5b                   	pop    %ebx
  8027fd:	5d                   	pop    %ebp
  8027fe:	c3                   	ret    

008027ff <nsipc_bind>:
	return r;
}

int
nsipc_bind(int s, struct sockaddr *name, socklen_t namelen)
{
  8027ff:	55                   	push   %ebp
  802800:	89 e5                	mov    %esp,%ebp
  802802:	53                   	push   %ebx
  802803:	83 ec 14             	sub    $0x14,%esp
  802806:	8b 5d 10             	mov    0x10(%ebp),%ebx
	nsipcbuf.bind.req_s = s;
  802809:	8b 45 08             	mov    0x8(%ebp),%eax
  80280c:	a3 00 60 80 00       	mov    %eax,0x806000
	memmove(&nsipcbuf.bind.req_name, name, namelen);
  802811:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  802815:	8b 45 0c             	mov    0xc(%ebp),%eax
  802818:	89 44 24 04          	mov    %eax,0x4(%esp)
  80281c:	c7 04 24 04 60 80 00 	movl   $0x806004,(%esp)
  802823:	e8 7d e5 ff ff       	call   800da5 <memmove>
	nsipcbuf.bind.req_namelen = namelen;
  802828:	89 1d 14 60 80 00    	mov    %ebx,0x806014
	return nsipc(NSREQ_BIND);
  80282e:	b8 02 00 00 00       	mov    $0x2,%eax
  802833:	e8 c8 fd ff ff       	call   802600 <nsipc>
}
  802838:	83 c4 14             	add    $0x14,%esp
  80283b:	5b                   	pop    %ebx
  80283c:	5d                   	pop    %ebp
  80283d:	c3                   	ret    

0080283e <nsipc_accept>:
    return r;
}

int
nsipc_accept(int s, struct sockaddr *addr, socklen_t *addrlen)
{
  80283e:	55                   	push   %ebp
  80283f:	89 e5                	mov    %esp,%ebp
  802841:	83 ec 18             	sub    $0x18,%esp
  802844:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  802847:	89 75 fc             	mov    %esi,-0x4(%ebp)
	int r;
	
	nsipcbuf.accept.req_s = s;
  80284a:	8b 45 08             	mov    0x8(%ebp),%eax
  80284d:	a3 00 60 80 00       	mov    %eax,0x806000
	if ((r = nsipc(NSREQ_ACCEPT)) >= 0) {
  802852:	b8 01 00 00 00       	mov    $0x1,%eax
  802857:	e8 a4 fd ff ff       	call   802600 <nsipc>
  80285c:	89 c3                	mov    %eax,%ebx
  80285e:	85 c0                	test   %eax,%eax
  802860:	78 25                	js     802887 <nsipc_accept+0x49>
		struct Nsret_accept *ret = &nsipcbuf.acceptRet;
		memmove(addr, &ret->ret_addr, ret->ret_addrlen);
  802862:	be 10 60 80 00       	mov    $0x806010,%esi
  802867:	8b 06                	mov    (%esi),%eax
  802869:	89 44 24 08          	mov    %eax,0x8(%esp)
  80286d:	c7 44 24 04 00 60 80 	movl   $0x806000,0x4(%esp)
  802874:	00 
  802875:	8b 45 0c             	mov    0xc(%ebp),%eax
  802878:	89 04 24             	mov    %eax,(%esp)
  80287b:	e8 25 e5 ff ff       	call   800da5 <memmove>
		*addrlen = ret->ret_addrlen;
  802880:	8b 16                	mov    (%esi),%edx
  802882:	8b 45 10             	mov    0x10(%ebp),%eax
  802885:	89 10                	mov    %edx,(%eax)
	}
	return r;
}
  802887:	89 d8                	mov    %ebx,%eax
  802889:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  80288c:	8b 75 fc             	mov    -0x4(%ebp),%esi
  80288f:	89 ec                	mov    %ebp,%esp
  802891:	5d                   	pop    %ebp
  802892:	c3                   	ret    
	...

008028a0 <devpipe_stat>:
	return i;
}

static int
devpipe_stat(struct Fd *fd, struct Stat *stat)
{
  8028a0:	55                   	push   %ebp
  8028a1:	89 e5                	mov    %esp,%ebp
  8028a3:	83 ec 18             	sub    $0x18,%esp
  8028a6:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  8028a9:	89 75 fc             	mov    %esi,-0x4(%ebp)
  8028ac:	8b 75 0c             	mov    0xc(%ebp),%esi
	struct Pipe *p = (struct Pipe*) fd2data(fd);
  8028af:	8b 45 08             	mov    0x8(%ebp),%eax
  8028b2:	89 04 24             	mov    %eax,(%esp)
  8028b5:	e8 c6 eb ff ff       	call   801480 <fd2data>
  8028ba:	89 c3                	mov    %eax,%ebx
	strcpy(stat->st_name, "<pipe>");
  8028bc:	c7 44 24 04 cb 36 80 	movl   $0x8036cb,0x4(%esp)
  8028c3:	00 
  8028c4:	89 34 24             	mov    %esi,(%esp)
  8028c7:	e8 1e e3 ff ff       	call   800bea <strcpy>
	stat->st_size = p->p_wpos - p->p_rpos;
  8028cc:	8b 43 04             	mov    0x4(%ebx),%eax
  8028cf:	2b 03                	sub    (%ebx),%eax
  8028d1:	89 86 80 00 00 00    	mov    %eax,0x80(%esi)
	stat->st_isdir = 0;
  8028d7:	c7 86 84 00 00 00 00 	movl   $0x0,0x84(%esi)
  8028de:	00 00 00 
	stat->st_dev = &devpipe;
  8028e1:	c7 86 88 00 00 00 c8 	movl   $0x8087c8,0x88(%esi)
  8028e8:	87 80 00 
	return 0;
}
  8028eb:	b8 00 00 00 00       	mov    $0x0,%eax
  8028f0:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  8028f3:	8b 75 fc             	mov    -0x4(%ebp),%esi
  8028f6:	89 ec                	mov    %ebp,%esp
  8028f8:	5d                   	pop    %ebp
  8028f9:	c3                   	ret    

008028fa <devpipe_close>:

static int
devpipe_close(struct Fd *fd)
{
  8028fa:	55                   	push   %ebp
  8028fb:	89 e5                	mov    %esp,%ebp
  8028fd:	53                   	push   %ebx
  8028fe:	83 ec 14             	sub    $0x14,%esp
  802901:	8b 5d 08             	mov    0x8(%ebp),%ebx
	(void) sys_page_unmap(0, fd);
  802904:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  802908:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  80290f:	e8 76 e9 ff ff       	call   80128a <sys_page_unmap>
	return sys_page_unmap(0, fd2data(fd));
  802914:	89 1c 24             	mov    %ebx,(%esp)
  802917:	e8 64 eb ff ff       	call   801480 <fd2data>
  80291c:	89 44 24 04          	mov    %eax,0x4(%esp)
  802920:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802927:	e8 5e e9 ff ff       	call   80128a <sys_page_unmap>
}
  80292c:	83 c4 14             	add    $0x14,%esp
  80292f:	5b                   	pop    %ebx
  802930:	5d                   	pop    %ebp
  802931:	c3                   	ret    

00802932 <_pipeisclosed>:
	return r;
}

static int
_pipeisclosed(struct Fd *fd, struct Pipe *p)
{
  802932:	55                   	push   %ebp
  802933:	89 e5                	mov    %esp,%ebp
  802935:	57                   	push   %edi
  802936:	56                   	push   %esi
  802937:	53                   	push   %ebx
  802938:	83 ec 2c             	sub    $0x2c,%esp
  80293b:	89 c7                	mov    %eax,%edi
  80293d:	89 55 e4             	mov    %edx,-0x1c(%ebp)
	int n, nn, ret;

	while (1) {
		n = env->env_runs;
  802940:	a1 70 9f 80 00       	mov    0x809f70,%eax
  802945:	8b 58 58             	mov    0x58(%eax),%ebx
		ret = pageref(fd) == pageref(p);
  802948:	89 3c 24             	mov    %edi,(%esp)
  80294b:	e8 54 04 00 00       	call   802da4 <pageref>
  802950:	89 c6                	mov    %eax,%esi
  802952:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  802955:	89 04 24             	mov    %eax,(%esp)
  802958:	e8 47 04 00 00       	call   802da4 <pageref>
  80295d:	39 c6                	cmp    %eax,%esi
  80295f:	0f 94 c0             	sete   %al
  802962:	0f b6 c0             	movzbl %al,%eax
		nn = env->env_runs;
  802965:	8b 15 70 9f 80 00    	mov    0x809f70,%edx
  80296b:	8b 4a 58             	mov    0x58(%edx),%ecx
		if (n == nn)
  80296e:	39 cb                	cmp    %ecx,%ebx
  802970:	75 08                	jne    80297a <_pipeisclosed+0x48>
			return ret;
		if (n != nn && ret == 1)
			cprintf("pipe race avoided\n", n, env->env_runs, ret);
	}
}
  802972:	83 c4 2c             	add    $0x2c,%esp
  802975:	5b                   	pop    %ebx
  802976:	5e                   	pop    %esi
  802977:	5f                   	pop    %edi
  802978:	5d                   	pop    %ebp
  802979:	c3                   	ret    
		n = env->env_runs;
		ret = pageref(fd) == pageref(p);
		nn = env->env_runs;
		if (n == nn)
			return ret;
		if (n != nn && ret == 1)
  80297a:	83 f8 01             	cmp    $0x1,%eax
  80297d:	75 c1                	jne    802940 <_pipeisclosed+0xe>
			cprintf("pipe race avoided\n", n, env->env_runs, ret);
  80297f:	8b 52 58             	mov    0x58(%edx),%edx
  802982:	89 44 24 0c          	mov    %eax,0xc(%esp)
  802986:	89 54 24 08          	mov    %edx,0x8(%esp)
  80298a:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  80298e:	c7 04 24 d2 36 80 00 	movl   $0x8036d2,(%esp)
  802995:	e8 7b db ff ff       	call   800515 <cprintf>
  80299a:	eb a4                	jmp    802940 <_pipeisclosed+0xe>

0080299c <devpipe_write>:
	return i;
}

static ssize_t
devpipe_write(struct Fd *fd, const void *vbuf, size_t n)
{
  80299c:	55                   	push   %ebp
  80299d:	89 e5                	mov    %esp,%ebp
  80299f:	57                   	push   %edi
  8029a0:	56                   	push   %esi
  8029a1:	53                   	push   %ebx
  8029a2:	83 ec 1c             	sub    $0x1c,%esp
  8029a5:	8b 75 08             	mov    0x8(%ebp),%esi
	const uint8_t *buf;
	size_t i;
	struct Pipe *p;

	p = (struct Pipe*) fd2data(fd);
  8029a8:	89 34 24             	mov    %esi,(%esp)
  8029ab:	e8 d0 ea ff ff       	call   801480 <fd2data>
  8029b0:	89 c3                	mov    %eax,%ebx
	if (debug)
		cprintf("[%08x] devpipe_write %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  8029b2:	bf 00 00 00 00       	mov    $0x0,%edi
  8029b7:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  8029bb:	75 54                	jne    802a11 <devpipe_write+0x75>
  8029bd:	eb 60                	jmp    802a1f <devpipe_write+0x83>
		while (p->p_wpos >= p->p_rpos + sizeof(p->p_buf)) {
			// pipe is full
			// if all the readers are gone
			// (it's only writers like us now),
			// note eof
			if (_pipeisclosed(fd, p))
  8029bf:	89 da                	mov    %ebx,%edx
  8029c1:	89 f0                	mov    %esi,%eax
  8029c3:	e8 6a ff ff ff       	call   802932 <_pipeisclosed>
  8029c8:	85 c0                	test   %eax,%eax
  8029ca:	74 07                	je     8029d3 <devpipe_write+0x37>
  8029cc:	b8 00 00 00 00       	mov    $0x0,%eax
  8029d1:	eb 53                	jmp    802a26 <devpipe_write+0x8a>
				return 0;
			// yield and see what happens
			if (debug)
				cprintf("devpipe_write yield\n");
			sys_yield();
  8029d3:	90                   	nop
  8029d4:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  8029d8:	e8 c8 e9 ff ff       	call   8013a5 <sys_yield>
		cprintf("[%08x] devpipe_write %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
		while (p->p_wpos >= p->p_rpos + sizeof(p->p_buf)) {
  8029dd:	8b 43 04             	mov    0x4(%ebx),%eax
  8029e0:	8b 13                	mov    (%ebx),%edx
  8029e2:	83 c2 20             	add    $0x20,%edx
  8029e5:	39 d0                	cmp    %edx,%eax
  8029e7:	73 d6                	jae    8029bf <devpipe_write+0x23>
				cprintf("devpipe_write yield\n");
			sys_yield();
		}
		// there's room for a byte.  store it.
		// wait to increment wpos until the byte is stored!
		p->p_buf[p->p_wpos % PIPEBUFSIZ] = buf[i];
  8029e9:	89 c2                	mov    %eax,%edx
  8029eb:	c1 fa 1f             	sar    $0x1f,%edx
  8029ee:	c1 ea 1b             	shr    $0x1b,%edx
  8029f1:	01 d0                	add    %edx,%eax
  8029f3:	83 e0 1f             	and    $0x1f,%eax
  8029f6:	29 d0                	sub    %edx,%eax
  8029f8:	89 c2                	mov    %eax,%edx
  8029fa:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  8029fd:	0f b6 04 39          	movzbl (%ecx,%edi,1),%eax
  802a01:	88 44 13 08          	mov    %al,0x8(%ebx,%edx,1)
		p->p_wpos++;
  802a05:	83 43 04 01          	addl   $0x1,0x4(%ebx)
	if (debug)
		cprintf("[%08x] devpipe_write %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  802a09:	83 c7 01             	add    $0x1,%edi
  802a0c:	39 7d 10             	cmp    %edi,0x10(%ebp)
  802a0f:	76 13                	jbe    802a24 <devpipe_write+0x88>
		while (p->p_wpos >= p->p_rpos + sizeof(p->p_buf)) {
  802a11:	8b 43 04             	mov    0x4(%ebx),%eax
  802a14:	8b 13                	mov    (%ebx),%edx
  802a16:	83 c2 20             	add    $0x20,%edx
  802a19:	39 d0                	cmp    %edx,%eax
  802a1b:	73 a2                	jae    8029bf <devpipe_write+0x23>
  802a1d:	eb ca                	jmp    8029e9 <devpipe_write+0x4d>
  802a1f:	bf 00 00 00 00       	mov    $0x0,%edi
		// wait to increment wpos until the byte is stored!
		p->p_buf[p->p_wpos % PIPEBUFSIZ] = buf[i];
		p->p_wpos++;
	}
	
	return i;
  802a24:	89 f8                	mov    %edi,%eax
}
  802a26:	83 c4 1c             	add    $0x1c,%esp
  802a29:	5b                   	pop    %ebx
  802a2a:	5e                   	pop    %esi
  802a2b:	5f                   	pop    %edi
  802a2c:	5d                   	pop    %ebp
  802a2d:	c3                   	ret    

00802a2e <devpipe_read>:
	return _pipeisclosed(fd, p);
}

static ssize_t
devpipe_read(struct Fd *fd, void *vbuf, size_t n)
{
  802a2e:	55                   	push   %ebp
  802a2f:	89 e5                	mov    %esp,%ebp
  802a31:	83 ec 28             	sub    $0x28,%esp
  802a34:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  802a37:	89 75 f8             	mov    %esi,-0x8(%ebp)
  802a3a:	89 7d fc             	mov    %edi,-0x4(%ebp)
  802a3d:	8b 7d 08             	mov    0x8(%ebp),%edi
	uint8_t *buf;
	size_t i;
	struct Pipe *p;

	p = (struct Pipe*)fd2data(fd);
  802a40:	89 3c 24             	mov    %edi,(%esp)
  802a43:	e8 38 ea ff ff       	call   801480 <fd2data>
  802a48:	89 c3                	mov    %eax,%ebx
	if (debug)
		cprintf("[%08x] devpipe_read %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  802a4a:	be 00 00 00 00       	mov    $0x0,%esi
  802a4f:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  802a53:	75 4c                	jne    802aa1 <devpipe_read+0x73>
  802a55:	eb 5b                	jmp    802ab2 <devpipe_read+0x84>
		while (p->p_rpos == p->p_wpos) {
			// pipe is empty
			// if we got any data, return it
			if (i > 0)
				return i;
  802a57:	89 f0                	mov    %esi,%eax
  802a59:	eb 5e                	jmp    802ab9 <devpipe_read+0x8b>
			// if all the writers are gone, note eof
			if (_pipeisclosed(fd, p))
  802a5b:	89 da                	mov    %ebx,%edx
  802a5d:	89 f8                	mov    %edi,%eax
  802a5f:	90                   	nop
  802a60:	e8 cd fe ff ff       	call   802932 <_pipeisclosed>
  802a65:	85 c0                	test   %eax,%eax
  802a67:	74 07                	je     802a70 <devpipe_read+0x42>
  802a69:	b8 00 00 00 00       	mov    $0x0,%eax
  802a6e:	eb 49                	jmp    802ab9 <devpipe_read+0x8b>
				return 0;
			// yield and see what happens
			if (debug)
				cprintf("devpipe_read yield\n");
			sys_yield();
  802a70:	e8 30 e9 ff ff       	call   8013a5 <sys_yield>
		cprintf("[%08x] devpipe_read %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
		while (p->p_rpos == p->p_wpos) {
  802a75:	8b 03                	mov    (%ebx),%eax
  802a77:	3b 43 04             	cmp    0x4(%ebx),%eax
  802a7a:	74 df                	je     802a5b <devpipe_read+0x2d>
				cprintf("devpipe_read yield\n");
			sys_yield();
		}
		// there's a byte.  take it.
		// wait to increment rpos until the byte is taken!
		buf[i] = p->p_buf[p->p_rpos % PIPEBUFSIZ];
  802a7c:	89 c2                	mov    %eax,%edx
  802a7e:	c1 fa 1f             	sar    $0x1f,%edx
  802a81:	c1 ea 1b             	shr    $0x1b,%edx
  802a84:	01 d0                	add    %edx,%eax
  802a86:	83 e0 1f             	and    $0x1f,%eax
  802a89:	29 d0                	sub    %edx,%eax
  802a8b:	0f b6 44 03 08       	movzbl 0x8(%ebx,%eax,1),%eax
  802a90:	8b 55 0c             	mov    0xc(%ebp),%edx
  802a93:	88 04 32             	mov    %al,(%edx,%esi,1)
		p->p_rpos++;
  802a96:	83 03 01             	addl   $0x1,(%ebx)
	if (debug)
		cprintf("[%08x] devpipe_read %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  802a99:	83 c6 01             	add    $0x1,%esi
  802a9c:	39 75 10             	cmp    %esi,0x10(%ebp)
  802a9f:	76 16                	jbe    802ab7 <devpipe_read+0x89>
		while (p->p_rpos == p->p_wpos) {
  802aa1:	8b 03                	mov    (%ebx),%eax
  802aa3:	3b 43 04             	cmp    0x4(%ebx),%eax
  802aa6:	75 d4                	jne    802a7c <devpipe_read+0x4e>
			// pipe is empty
			// if we got any data, return it
			if (i > 0)
  802aa8:	85 f6                	test   %esi,%esi
  802aaa:	75 ab                	jne    802a57 <devpipe_read+0x29>
  802aac:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802ab0:	eb a9                	jmp    802a5b <devpipe_read+0x2d>
  802ab2:	be 00 00 00 00       	mov    $0x0,%esi
		// there's a byte.  take it.
		// wait to increment rpos until the byte is taken!
		buf[i] = p->p_buf[p->p_rpos % PIPEBUFSIZ];
		p->p_rpos++;
	}
	return i;
  802ab7:	89 f0                	mov    %esi,%eax
}
  802ab9:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  802abc:	8b 75 f8             	mov    -0x8(%ebp),%esi
  802abf:	8b 7d fc             	mov    -0x4(%ebp),%edi
  802ac2:	89 ec                	mov    %ebp,%esp
  802ac4:	5d                   	pop    %ebp
  802ac5:	c3                   	ret    

00802ac6 <pipeisclosed>:
	}
}

int
pipeisclosed(int fdnum)
{
  802ac6:	55                   	push   %ebp
  802ac7:	89 e5                	mov    %esp,%ebp
  802ac9:	83 ec 28             	sub    $0x28,%esp
	struct Fd *fd;
	struct Pipe *p;
	int r;

	if ((r = fd_lookup(fdnum, &fd)) < 0)
  802acc:	8d 45 f4             	lea    -0xc(%ebp),%eax
  802acf:	89 44 24 04          	mov    %eax,0x4(%esp)
  802ad3:	8b 45 08             	mov    0x8(%ebp),%eax
  802ad6:	89 04 24             	mov    %eax,(%esp)
  802ad9:	e8 2f ea ff ff       	call   80150d <fd_lookup>
  802ade:	85 c0                	test   %eax,%eax
  802ae0:	78 15                	js     802af7 <pipeisclosed+0x31>
		return r;
	p = (struct Pipe*) fd2data(fd);
  802ae2:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802ae5:	89 04 24             	mov    %eax,(%esp)
  802ae8:	e8 93 e9 ff ff       	call   801480 <fd2data>
	return _pipeisclosed(fd, p);
  802aed:	89 c2                	mov    %eax,%edx
  802aef:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802af2:	e8 3b fe ff ff       	call   802932 <_pipeisclosed>
}
  802af7:	c9                   	leave  
  802af8:	c3                   	ret    

00802af9 <pipe>:
	uint8_t p_buf[PIPEBUFSIZ];	// data buffer
};

int
pipe(int pfd[2])
{
  802af9:	55                   	push   %ebp
  802afa:	89 e5                	mov    %esp,%ebp
  802afc:	83 ec 48             	sub    $0x48,%esp
  802aff:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  802b02:	89 75 f8             	mov    %esi,-0x8(%ebp)
  802b05:	89 7d fc             	mov    %edi,-0x4(%ebp)
  802b08:	8b 7d 08             	mov    0x8(%ebp),%edi
	int r;
	struct Fd *fd0, *fd1;
	void *va;

	// allocate the file descriptor table entries
	if ((r = fd_alloc(&fd0)) < 0
  802b0b:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  802b0e:	89 04 24             	mov    %eax,(%esp)
  802b11:	e8 85 e9 ff ff       	call   80149b <fd_alloc>
  802b16:	89 c3                	mov    %eax,%ebx
  802b18:	85 c0                	test   %eax,%eax
  802b1a:	0f 88 42 01 00 00    	js     802c62 <pipe+0x169>
	    || (r = sys_page_alloc(0, fd0, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  802b20:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  802b27:	00 
  802b28:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  802b2b:	89 44 24 04          	mov    %eax,0x4(%esp)
  802b2f:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802b36:	e8 0b e8 ff ff       	call   801346 <sys_page_alloc>
  802b3b:	89 c3                	mov    %eax,%ebx
	int r;
	struct Fd *fd0, *fd1;
	void *va;

	// allocate the file descriptor table entries
	if ((r = fd_alloc(&fd0)) < 0
  802b3d:	85 c0                	test   %eax,%eax
  802b3f:	0f 88 1d 01 00 00    	js     802c62 <pipe+0x169>
	    || (r = sys_page_alloc(0, fd0, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
		goto err;

	if ((r = fd_alloc(&fd1)) < 0
  802b45:	8d 45 e0             	lea    -0x20(%ebp),%eax
  802b48:	89 04 24             	mov    %eax,(%esp)
  802b4b:	e8 4b e9 ff ff       	call   80149b <fd_alloc>
  802b50:	89 c3                	mov    %eax,%ebx
  802b52:	85 c0                	test   %eax,%eax
  802b54:	0f 88 f5 00 00 00    	js     802c4f <pipe+0x156>
	    || (r = sys_page_alloc(0, fd1, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  802b5a:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  802b61:	00 
  802b62:	8b 45 e0             	mov    -0x20(%ebp),%eax
  802b65:	89 44 24 04          	mov    %eax,0x4(%esp)
  802b69:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802b70:	e8 d1 e7 ff ff       	call   801346 <sys_page_alloc>
  802b75:	89 c3                	mov    %eax,%ebx
	// allocate the file descriptor table entries
	if ((r = fd_alloc(&fd0)) < 0
	    || (r = sys_page_alloc(0, fd0, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
		goto err;

	if ((r = fd_alloc(&fd1)) < 0
  802b77:	85 c0                	test   %eax,%eax
  802b79:	0f 88 d0 00 00 00    	js     802c4f <pipe+0x156>
	    || (r = sys_page_alloc(0, fd1, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
		goto err1;

	// allocate the pipe structure as first data page in both
	va = fd2data(fd0);
  802b7f:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  802b82:	89 04 24             	mov    %eax,(%esp)
  802b85:	e8 f6 e8 ff ff       	call   801480 <fd2data>
  802b8a:	89 c6                	mov    %eax,%esi
	if ((r = sys_page_alloc(0, va, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  802b8c:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  802b93:	00 
  802b94:	89 44 24 04          	mov    %eax,0x4(%esp)
  802b98:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802b9f:	e8 a2 e7 ff ff       	call   801346 <sys_page_alloc>
  802ba4:	89 c3                	mov    %eax,%ebx
  802ba6:	85 c0                	test   %eax,%eax
  802ba8:	0f 88 8e 00 00 00    	js     802c3c <pipe+0x143>
		goto err2;
	if ((r = sys_page_map(0, va, 0, fd2data(fd1), PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  802bae:	8b 45 e0             	mov    -0x20(%ebp),%eax
  802bb1:	89 04 24             	mov    %eax,(%esp)
  802bb4:	e8 c7 e8 ff ff       	call   801480 <fd2data>
  802bb9:	c7 44 24 10 07 04 00 	movl   $0x407,0x10(%esp)
  802bc0:	00 
  802bc1:	89 44 24 0c          	mov    %eax,0xc(%esp)
  802bc5:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  802bcc:	00 
  802bcd:	89 74 24 04          	mov    %esi,0x4(%esp)
  802bd1:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802bd8:	e8 0b e7 ff ff       	call   8012e8 <sys_page_map>
  802bdd:	89 c3                	mov    %eax,%ebx
  802bdf:	85 c0                	test   %eax,%eax
  802be1:	78 49                	js     802c2c <pipe+0x133>
		goto err3;

	// set up fd structures
	fd0->fd_dev_id = devpipe.dev_id;
  802be3:	b8 c8 87 80 00       	mov    $0x8087c8,%eax
  802be8:	8b 08                	mov    (%eax),%ecx
  802bea:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  802bed:	89 0a                	mov    %ecx,(%edx)
	fd0->fd_omode = O_RDONLY;
  802bef:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  802bf2:	c7 42 08 00 00 00 00 	movl   $0x0,0x8(%edx)

	fd1->fd_dev_id = devpipe.dev_id;
  802bf9:	8b 10                	mov    (%eax),%edx
  802bfb:	8b 45 e0             	mov    -0x20(%ebp),%eax
  802bfe:	89 10                	mov    %edx,(%eax)
	fd1->fd_omode = O_WRONLY;
  802c00:	8b 45 e0             	mov    -0x20(%ebp),%eax
  802c03:	c7 40 08 01 00 00 00 	movl   $0x1,0x8(%eax)

	if (debug)
		cprintf("[%08x] pipecreate %08x\n", env->env_id, vpt[VPN(va)]);

	pfd[0] = fd2num(fd0);
  802c0a:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  802c0d:	89 04 24             	mov    %eax,(%esp)
  802c10:	e8 5b e8 ff ff       	call   801470 <fd2num>
  802c15:	89 07                	mov    %eax,(%edi)
	pfd[1] = fd2num(fd1);
  802c17:	8b 45 e0             	mov    -0x20(%ebp),%eax
  802c1a:	89 04 24             	mov    %eax,(%esp)
  802c1d:	e8 4e e8 ff ff       	call   801470 <fd2num>
  802c22:	89 47 04             	mov    %eax,0x4(%edi)
  802c25:	bb 00 00 00 00       	mov    $0x0,%ebx
	return 0;
  802c2a:	eb 36                	jmp    802c62 <pipe+0x169>

    err3:
	sys_page_unmap(0, va);
  802c2c:	89 74 24 04          	mov    %esi,0x4(%esp)
  802c30:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802c37:	e8 4e e6 ff ff       	call   80128a <sys_page_unmap>
    err2:
	sys_page_unmap(0, fd1);
  802c3c:	8b 45 e0             	mov    -0x20(%ebp),%eax
  802c3f:	89 44 24 04          	mov    %eax,0x4(%esp)
  802c43:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802c4a:	e8 3b e6 ff ff       	call   80128a <sys_page_unmap>
    err1:
	sys_page_unmap(0, fd0);
  802c4f:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  802c52:	89 44 24 04          	mov    %eax,0x4(%esp)
  802c56:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802c5d:	e8 28 e6 ff ff       	call   80128a <sys_page_unmap>
    err:
	return r;
}
  802c62:	89 d8                	mov    %ebx,%eax
  802c64:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  802c67:	8b 75 f8             	mov    -0x8(%ebp),%esi
  802c6a:	8b 7d fc             	mov    -0x4(%ebp),%edi
  802c6d:	89 ec                	mov    %ebp,%esp
  802c6f:	5d                   	pop    %ebp
  802c70:	c3                   	ret    
  802c71:	00 00                	add    %al,(%eax)
	...

00802c74 <wait>:
#include <inc/lib.h>

// Waits until 'envid' exits.
void
wait(envid_t envid)
{
  802c74:	55                   	push   %ebp
  802c75:	89 e5                	mov    %esp,%ebp
  802c77:	56                   	push   %esi
  802c78:	53                   	push   %ebx
  802c79:	83 ec 10             	sub    $0x10,%esp
  802c7c:	8b 45 08             	mov    0x8(%ebp),%eax
	volatile struct Env *e;

	assert(envid != 0);
  802c7f:	85 c0                	test   %eax,%eax
  802c81:	75 24                	jne    802ca7 <wait+0x33>
  802c83:	c7 44 24 0c ea 36 80 	movl   $0x8036ea,0xc(%esp)
  802c8a:	00 
  802c8b:	c7 44 24 08 c2 35 80 	movl   $0x8035c2,0x8(%esp)
  802c92:	00 
  802c93:	c7 44 24 04 09 00 00 	movl   $0x9,0x4(%esp)
  802c9a:	00 
  802c9b:	c7 04 24 f5 36 80 00 	movl   $0x8036f5,(%esp)
  802ca2:	e8 a9 d7 ff ff       	call   800450 <_panic>
	e = &envs[ENVX(envid)];
  802ca7:	89 c3                	mov    %eax,%ebx
  802ca9:	81 e3 ff 03 00 00    	and    $0x3ff,%ebx
  802caf:	6b db 7c             	imul   $0x7c,%ebx,%ebx
  802cb2:	81 c3 00 00 c0 ee    	add    $0xeec00000,%ebx
	while (e->env_id == envid && e->env_status != ENV_FREE)
  802cb8:	8b 73 4c             	mov    0x4c(%ebx),%esi
  802cbb:	39 c6                	cmp    %eax,%esi
  802cbd:	75 1a                	jne    802cd9 <wait+0x65>
  802cbf:	8b 43 54             	mov    0x54(%ebx),%eax
  802cc2:	85 c0                	test   %eax,%eax
  802cc4:	74 13                	je     802cd9 <wait+0x65>
		sys_yield();
  802cc6:	e8 da e6 ff ff       	call   8013a5 <sys_yield>
{
	volatile struct Env *e;

	assert(envid != 0);
	e = &envs[ENVX(envid)];
	while (e->env_id == envid && e->env_status != ENV_FREE)
  802ccb:	8b 43 4c             	mov    0x4c(%ebx),%eax
  802cce:	39 f0                	cmp    %esi,%eax
  802cd0:	75 07                	jne    802cd9 <wait+0x65>
  802cd2:	8b 43 54             	mov    0x54(%ebx),%eax
  802cd5:	85 c0                	test   %eax,%eax
  802cd7:	75 ed                	jne    802cc6 <wait+0x52>
		sys_yield();
}
  802cd9:	83 c4 10             	add    $0x10,%esp
  802cdc:	5b                   	pop    %ebx
  802cdd:	5e                   	pop    %esi
  802cde:	5d                   	pop    %ebp
  802cdf:	c3                   	ret    

00802ce0 <ipc_send>:
//   Use sys_yield() to be CPU-friendly.
//   If 'pg' is null, pass sys_ipc_recv a value that it will understand
//   as meaning "no page".  (Zero is not the right value.)
void
ipc_send(envid_t to_env, uint32_t val, void *pg, int perm)
{
  802ce0:	55                   	push   %ebp
  802ce1:	89 e5                	mov    %esp,%ebp
  802ce3:	57                   	push   %edi
  802ce4:	56                   	push   %esi
  802ce5:	53                   	push   %ebx
  802ce6:	83 ec 2c             	sub    $0x2c,%esp
  802ce9:	8b 75 08             	mov    0x8(%ebp),%esi
  802cec:	8b 7d 0c             	mov    0xc(%ebp),%edi
  802cef:	8b 5d 10             	mov    0x10(%ebp),%ebx
  int r   = 0;
  while (1) {
    if ((r=sys_ipc_try_send(to_env, val, (pg==NULL?(void *)UTOP:pg), perm)) == -E_IPC_NOT_RECV)
  802cf2:	85 db                	test   %ebx,%ebx
  802cf4:	b8 00 00 c0 ee       	mov    $0xeec00000,%eax
  802cf9:	0f 45 c3             	cmovne %ebx,%eax
  802cfc:	8b 55 14             	mov    0x14(%ebp),%edx
  802cff:	89 54 24 0c          	mov    %edx,0xc(%esp)
  802d03:	89 44 24 08          	mov    %eax,0x8(%esp)
  802d07:	89 7c 24 04          	mov    %edi,0x4(%esp)
  802d0b:	89 34 24             	mov    %esi,(%esp)
  802d0e:	e8 fd e3 ff ff       	call   801110 <sys_ipc_try_send>
  802d13:	83 f8 f9             	cmp    $0xfffffff9,%eax
  802d16:	75 0a                	jne    802d22 <ipc_send+0x42>
      sys_yield();
  802d18:	e8 88 e6 ff ff       	call   8013a5 <sys_yield>
    else if (r < 0)
      panic("ipc_send to [%x] failed. Error: %x\n", to_env, r);
    else
      return;
  }
  802d1d:	8d 76 00             	lea    0x0(%esi),%esi
  802d20:	eb d0                	jmp    802cf2 <ipc_send+0x12>
{
  int r   = 0;
  while (1) {
    if ((r=sys_ipc_try_send(to_env, val, (pg==NULL?(void *)UTOP:pg), perm)) == -E_IPC_NOT_RECV)
      sys_yield();
    else if (r < 0)
  802d22:	85 c0                	test   %eax,%eax
  802d24:	79 24                	jns    802d4a <ipc_send+0x6a>
      panic("ipc_send to [%x] failed. Error: %x\n", to_env, r);
  802d26:	89 44 24 10          	mov    %eax,0x10(%esp)
  802d2a:	89 74 24 0c          	mov    %esi,0xc(%esp)
  802d2e:	c7 44 24 08 00 37 80 	movl   $0x803700,0x8(%esp)
  802d35:	00 
  802d36:	c7 44 24 04 36 00 00 	movl   $0x36,0x4(%esp)
  802d3d:	00 
  802d3e:	c7 04 24 24 37 80 00 	movl   $0x803724,(%esp)
  802d45:	e8 06 d7 ff ff       	call   800450 <_panic>
    else
      return;
  }
}
  802d4a:	83 c4 2c             	add    $0x2c,%esp
  802d4d:	5b                   	pop    %ebx
  802d4e:	5e                   	pop    %esi
  802d4f:	5f                   	pop    %edi
  802d50:	5d                   	pop    %ebp
  802d51:	c3                   	ret    

00802d52 <ipc_recv>:
//   If 'pg' is null, pass sys_ipc_recv a value that it will understand
//   as meaning "no page".  (Zero is not the right value, since that's
//   a perfectly valid place to map a page.)
int32_t
ipc_recv(envid_t *from_env_store, void *pg, int *perm_store)
{
  802d52:	55                   	push   %ebp
  802d53:	89 e5                	mov    %esp,%ebp
  802d55:	56                   	push   %esi
  802d56:	53                   	push   %ebx
  802d57:	83 ec 10             	sub    $0x10,%esp
  802d5a:	8b 5d 08             	mov    0x8(%ebp),%ebx
  802d5d:	8b 45 0c             	mov    0xc(%ebp),%eax
  802d60:	8b 75 10             	mov    0x10(%ebp),%esi
  int r;
  if ((r=sys_ipc_recv((pg==NULL?(void *)UTOP:pg)))<0)
  802d63:	85 c0                	test   %eax,%eax
  802d65:	ba 00 00 c0 ee       	mov    $0xeec00000,%edx
  802d6a:	0f 44 c2             	cmove  %edx,%eax
  802d6d:	89 04 24             	mov    %eax,(%esp)
  802d70:	e8 3e e3 ff ff       	call   8010b3 <sys_ipc_recv>
  802d75:	85 c0                	test   %eax,%eax
  802d77:	78 24                	js     802d9d <ipc_recv+0x4b>
    return r;

  if (from_env_store)
  802d79:	85 db                	test   %ebx,%ebx
  802d7b:	74 0a                	je     802d87 <ipc_recv+0x35>
    *from_env_store = env->env_ipc_from;
  802d7d:	a1 70 9f 80 00       	mov    0x809f70,%eax
  802d82:	8b 40 74             	mov    0x74(%eax),%eax
  802d85:	89 03                	mov    %eax,(%ebx)

  if (perm_store)
  802d87:	85 f6                	test   %esi,%esi
  802d89:	74 0a                	je     802d95 <ipc_recv+0x43>
    *perm_store     = env->env_ipc_perm;
  802d8b:	a1 70 9f 80 00       	mov    0x809f70,%eax
  802d90:	8b 40 78             	mov    0x78(%eax),%eax
  802d93:	89 06                	mov    %eax,(%esi)

  return env->env_ipc_value;
  802d95:	a1 70 9f 80 00       	mov    0x809f70,%eax
  802d9a:	8b 40 70             	mov    0x70(%eax),%eax
}
  802d9d:	83 c4 10             	add    $0x10,%esp
  802da0:	5b                   	pop    %ebx
  802da1:	5e                   	pop    %esi
  802da2:	5d                   	pop    %ebp
  802da3:	c3                   	ret    

00802da4 <pageref>:
#include <inc/lib.h>

int
pageref(void *v)
{
  802da4:	55                   	push   %ebp
  802da5:	89 e5                	mov    %esp,%ebp
	pte_t pte;

	if (!(vpd[PDX(v)] & PTE_P))
  802da7:	8b 45 08             	mov    0x8(%ebp),%eax
  802daa:	89 c2                	mov    %eax,%edx
  802dac:	c1 ea 16             	shr    $0x16,%edx
  802daf:	8b 14 95 00 d0 7b ef 	mov    -0x10843000(,%edx,4),%edx
  802db6:	f6 c2 01             	test   $0x1,%dl
  802db9:	74 26                	je     802de1 <pageref+0x3d>
		return 0;
	pte = vpt[VPN(v)];
  802dbb:	c1 e8 0c             	shr    $0xc,%eax
  802dbe:	8b 04 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%eax
	if (!(pte & PTE_P))
  802dc5:	a8 01                	test   $0x1,%al
  802dc7:	74 18                	je     802de1 <pageref+0x3d>
		return 0;
	return pages[PPN(pte)].pp_ref;
  802dc9:	c1 e8 0c             	shr    $0xc,%eax
  802dcc:	8d 14 40             	lea    (%eax,%eax,2),%edx
  802dcf:	c1 e2 02             	shl    $0x2,%edx
  802dd2:	b8 00 00 00 ef       	mov    $0xef000000,%eax
  802dd7:	0f b7 44 02 08       	movzwl 0x8(%edx,%eax,1),%eax
  802ddc:	0f b7 c0             	movzwl %ax,%eax
  802ddf:	eb 05                	jmp    802de6 <pageref+0x42>
  802de1:	b8 00 00 00 00       	mov    $0x0,%eax
}
  802de6:	5d                   	pop    %ebp
  802de7:	c3                   	ret    
	...

00802df0 <__udivdi3>:
  802df0:	55                   	push   %ebp
  802df1:	89 e5                	mov    %esp,%ebp
  802df3:	57                   	push   %edi
  802df4:	56                   	push   %esi
  802df5:	83 ec 10             	sub    $0x10,%esp
  802df8:	8b 45 14             	mov    0x14(%ebp),%eax
  802dfb:	8b 55 08             	mov    0x8(%ebp),%edx
  802dfe:	8b 75 10             	mov    0x10(%ebp),%esi
  802e01:	8b 7d 0c             	mov    0xc(%ebp),%edi
  802e04:	85 c0                	test   %eax,%eax
  802e06:	89 55 f0             	mov    %edx,-0x10(%ebp)
  802e09:	75 35                	jne    802e40 <__udivdi3+0x50>
  802e0b:	39 fe                	cmp    %edi,%esi
  802e0d:	77 61                	ja     802e70 <__udivdi3+0x80>
  802e0f:	85 f6                	test   %esi,%esi
  802e11:	75 0b                	jne    802e1e <__udivdi3+0x2e>
  802e13:	b8 01 00 00 00       	mov    $0x1,%eax
  802e18:	31 d2                	xor    %edx,%edx
  802e1a:	f7 f6                	div    %esi
  802e1c:	89 c6                	mov    %eax,%esi
  802e1e:	8b 4d f0             	mov    -0x10(%ebp),%ecx
  802e21:	31 d2                	xor    %edx,%edx
  802e23:	89 f8                	mov    %edi,%eax
  802e25:	f7 f6                	div    %esi
  802e27:	89 c7                	mov    %eax,%edi
  802e29:	89 c8                	mov    %ecx,%eax
  802e2b:	f7 f6                	div    %esi
  802e2d:	89 c1                	mov    %eax,%ecx
  802e2f:	89 fa                	mov    %edi,%edx
  802e31:	89 c8                	mov    %ecx,%eax
  802e33:	83 c4 10             	add    $0x10,%esp
  802e36:	5e                   	pop    %esi
  802e37:	5f                   	pop    %edi
  802e38:	5d                   	pop    %ebp
  802e39:	c3                   	ret    
  802e3a:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  802e40:	39 f8                	cmp    %edi,%eax
  802e42:	77 1c                	ja     802e60 <__udivdi3+0x70>
  802e44:	0f bd d0             	bsr    %eax,%edx
  802e47:	83 f2 1f             	xor    $0x1f,%edx
  802e4a:	89 55 f4             	mov    %edx,-0xc(%ebp)
  802e4d:	75 39                	jne    802e88 <__udivdi3+0x98>
  802e4f:	3b 75 f0             	cmp    -0x10(%ebp),%esi
  802e52:	0f 86 a0 00 00 00    	jbe    802ef8 <__udivdi3+0x108>
  802e58:	39 f8                	cmp    %edi,%eax
  802e5a:	0f 82 98 00 00 00    	jb     802ef8 <__udivdi3+0x108>
  802e60:	31 ff                	xor    %edi,%edi
  802e62:	31 c9                	xor    %ecx,%ecx
  802e64:	89 c8                	mov    %ecx,%eax
  802e66:	89 fa                	mov    %edi,%edx
  802e68:	83 c4 10             	add    $0x10,%esp
  802e6b:	5e                   	pop    %esi
  802e6c:	5f                   	pop    %edi
  802e6d:	5d                   	pop    %ebp
  802e6e:	c3                   	ret    
  802e6f:	90                   	nop
  802e70:	89 d1                	mov    %edx,%ecx
  802e72:	89 fa                	mov    %edi,%edx
  802e74:	89 c8                	mov    %ecx,%eax
  802e76:	31 ff                	xor    %edi,%edi
  802e78:	f7 f6                	div    %esi
  802e7a:	89 c1                	mov    %eax,%ecx
  802e7c:	89 fa                	mov    %edi,%edx
  802e7e:	89 c8                	mov    %ecx,%eax
  802e80:	83 c4 10             	add    $0x10,%esp
  802e83:	5e                   	pop    %esi
  802e84:	5f                   	pop    %edi
  802e85:	5d                   	pop    %ebp
  802e86:	c3                   	ret    
  802e87:	90                   	nop
  802e88:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  802e8c:	89 f2                	mov    %esi,%edx
  802e8e:	d3 e0                	shl    %cl,%eax
  802e90:	89 45 ec             	mov    %eax,-0x14(%ebp)
  802e93:	b8 20 00 00 00       	mov    $0x20,%eax
  802e98:	2b 45 f4             	sub    -0xc(%ebp),%eax
  802e9b:	89 c1                	mov    %eax,%ecx
  802e9d:	d3 ea                	shr    %cl,%edx
  802e9f:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  802ea3:	0b 55 ec             	or     -0x14(%ebp),%edx
  802ea6:	d3 e6                	shl    %cl,%esi
  802ea8:	89 c1                	mov    %eax,%ecx
  802eaa:	89 75 e8             	mov    %esi,-0x18(%ebp)
  802ead:	89 fe                	mov    %edi,%esi
  802eaf:	d3 ee                	shr    %cl,%esi
  802eb1:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  802eb5:	89 55 ec             	mov    %edx,-0x14(%ebp)
  802eb8:	8b 55 f0             	mov    -0x10(%ebp),%edx
  802ebb:	d3 e7                	shl    %cl,%edi
  802ebd:	89 c1                	mov    %eax,%ecx
  802ebf:	d3 ea                	shr    %cl,%edx
  802ec1:	09 d7                	or     %edx,%edi
  802ec3:	89 f2                	mov    %esi,%edx
  802ec5:	89 f8                	mov    %edi,%eax
  802ec7:	f7 75 ec             	divl   -0x14(%ebp)
  802eca:	89 d6                	mov    %edx,%esi
  802ecc:	89 c7                	mov    %eax,%edi
  802ece:	f7 65 e8             	mull   -0x18(%ebp)
  802ed1:	39 d6                	cmp    %edx,%esi
  802ed3:	89 55 ec             	mov    %edx,-0x14(%ebp)
  802ed6:	72 30                	jb     802f08 <__udivdi3+0x118>
  802ed8:	8b 55 f0             	mov    -0x10(%ebp),%edx
  802edb:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  802edf:	d3 e2                	shl    %cl,%edx
  802ee1:	39 c2                	cmp    %eax,%edx
  802ee3:	73 05                	jae    802eea <__udivdi3+0xfa>
  802ee5:	3b 75 ec             	cmp    -0x14(%ebp),%esi
  802ee8:	74 1e                	je     802f08 <__udivdi3+0x118>
  802eea:	89 f9                	mov    %edi,%ecx
  802eec:	31 ff                	xor    %edi,%edi
  802eee:	e9 71 ff ff ff       	jmp    802e64 <__udivdi3+0x74>
  802ef3:	90                   	nop
  802ef4:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802ef8:	31 ff                	xor    %edi,%edi
  802efa:	b9 01 00 00 00       	mov    $0x1,%ecx
  802eff:	e9 60 ff ff ff       	jmp    802e64 <__udivdi3+0x74>
  802f04:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802f08:	8d 4f ff             	lea    -0x1(%edi),%ecx
  802f0b:	31 ff                	xor    %edi,%edi
  802f0d:	89 c8                	mov    %ecx,%eax
  802f0f:	89 fa                	mov    %edi,%edx
  802f11:	83 c4 10             	add    $0x10,%esp
  802f14:	5e                   	pop    %esi
  802f15:	5f                   	pop    %edi
  802f16:	5d                   	pop    %ebp
  802f17:	c3                   	ret    
	...

00802f20 <__umoddi3>:
  802f20:	55                   	push   %ebp
  802f21:	89 e5                	mov    %esp,%ebp
  802f23:	57                   	push   %edi
  802f24:	56                   	push   %esi
  802f25:	83 ec 20             	sub    $0x20,%esp
  802f28:	8b 55 14             	mov    0x14(%ebp),%edx
  802f2b:	8b 4d 08             	mov    0x8(%ebp),%ecx
  802f2e:	8b 7d 10             	mov    0x10(%ebp),%edi
  802f31:	8b 75 0c             	mov    0xc(%ebp),%esi
  802f34:	85 d2                	test   %edx,%edx
  802f36:	89 c8                	mov    %ecx,%eax
  802f38:	89 4d f4             	mov    %ecx,-0xc(%ebp)
  802f3b:	75 13                	jne    802f50 <__umoddi3+0x30>
  802f3d:	39 f7                	cmp    %esi,%edi
  802f3f:	76 3f                	jbe    802f80 <__umoddi3+0x60>
  802f41:	89 f2                	mov    %esi,%edx
  802f43:	f7 f7                	div    %edi
  802f45:	89 d0                	mov    %edx,%eax
  802f47:	31 d2                	xor    %edx,%edx
  802f49:	83 c4 20             	add    $0x20,%esp
  802f4c:	5e                   	pop    %esi
  802f4d:	5f                   	pop    %edi
  802f4e:	5d                   	pop    %ebp
  802f4f:	c3                   	ret    
  802f50:	39 f2                	cmp    %esi,%edx
  802f52:	77 4c                	ja     802fa0 <__umoddi3+0x80>
  802f54:	0f bd ca             	bsr    %edx,%ecx
  802f57:	83 f1 1f             	xor    $0x1f,%ecx
  802f5a:	89 4d f0             	mov    %ecx,-0x10(%ebp)
  802f5d:	75 51                	jne    802fb0 <__umoddi3+0x90>
  802f5f:	3b 7d f4             	cmp    -0xc(%ebp),%edi
  802f62:	0f 87 e0 00 00 00    	ja     803048 <__umoddi3+0x128>
  802f68:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802f6b:	29 f8                	sub    %edi,%eax
  802f6d:	19 d6                	sbb    %edx,%esi
  802f6f:	89 45 f4             	mov    %eax,-0xc(%ebp)
  802f72:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802f75:	89 f2                	mov    %esi,%edx
  802f77:	83 c4 20             	add    $0x20,%esp
  802f7a:	5e                   	pop    %esi
  802f7b:	5f                   	pop    %edi
  802f7c:	5d                   	pop    %ebp
  802f7d:	c3                   	ret    
  802f7e:	66 90                	xchg   %ax,%ax
  802f80:	85 ff                	test   %edi,%edi
  802f82:	75 0b                	jne    802f8f <__umoddi3+0x6f>
  802f84:	b8 01 00 00 00       	mov    $0x1,%eax
  802f89:	31 d2                	xor    %edx,%edx
  802f8b:	f7 f7                	div    %edi
  802f8d:	89 c7                	mov    %eax,%edi
  802f8f:	89 f0                	mov    %esi,%eax
  802f91:	31 d2                	xor    %edx,%edx
  802f93:	f7 f7                	div    %edi
  802f95:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802f98:	f7 f7                	div    %edi
  802f9a:	eb a9                	jmp    802f45 <__umoddi3+0x25>
  802f9c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802fa0:	89 c8                	mov    %ecx,%eax
  802fa2:	89 f2                	mov    %esi,%edx
  802fa4:	83 c4 20             	add    $0x20,%esp
  802fa7:	5e                   	pop    %esi
  802fa8:	5f                   	pop    %edi
  802fa9:	5d                   	pop    %ebp
  802faa:	c3                   	ret    
  802fab:	90                   	nop
  802fac:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802fb0:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  802fb4:	d3 e2                	shl    %cl,%edx
  802fb6:	89 55 f4             	mov    %edx,-0xc(%ebp)
  802fb9:	ba 20 00 00 00       	mov    $0x20,%edx
  802fbe:	2b 55 f0             	sub    -0x10(%ebp),%edx
  802fc1:	89 55 ec             	mov    %edx,-0x14(%ebp)
  802fc4:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  802fc8:	89 fa                	mov    %edi,%edx
  802fca:	d3 ea                	shr    %cl,%edx
  802fcc:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  802fd0:	0b 55 f4             	or     -0xc(%ebp),%edx
  802fd3:	d3 e7                	shl    %cl,%edi
  802fd5:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  802fd9:	89 55 f4             	mov    %edx,-0xc(%ebp)
  802fdc:	89 f2                	mov    %esi,%edx
  802fde:	89 7d e8             	mov    %edi,-0x18(%ebp)
  802fe1:	89 c7                	mov    %eax,%edi
  802fe3:	d3 ea                	shr    %cl,%edx
  802fe5:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  802fe9:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  802fec:	89 c2                	mov    %eax,%edx
  802fee:	d3 e6                	shl    %cl,%esi
  802ff0:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  802ff4:	d3 ea                	shr    %cl,%edx
  802ff6:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  802ffa:	09 d6                	or     %edx,%esi
  802ffc:	89 f0                	mov    %esi,%eax
  802ffe:	8b 75 e4             	mov    -0x1c(%ebp),%esi
  803001:	d3 e7                	shl    %cl,%edi
  803003:	89 f2                	mov    %esi,%edx
  803005:	f7 75 f4             	divl   -0xc(%ebp)
  803008:	89 d6                	mov    %edx,%esi
  80300a:	f7 65 e8             	mull   -0x18(%ebp)
  80300d:	39 d6                	cmp    %edx,%esi
  80300f:	72 2b                	jb     80303c <__umoddi3+0x11c>
  803011:	39 c7                	cmp    %eax,%edi
  803013:	72 23                	jb     803038 <__umoddi3+0x118>
  803015:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  803019:	29 c7                	sub    %eax,%edi
  80301b:	19 d6                	sbb    %edx,%esi
  80301d:	89 f0                	mov    %esi,%eax
  80301f:	89 f2                	mov    %esi,%edx
  803021:	d3 ef                	shr    %cl,%edi
  803023:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  803027:	d3 e0                	shl    %cl,%eax
  803029:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  80302d:	09 f8                	or     %edi,%eax
  80302f:	d3 ea                	shr    %cl,%edx
  803031:	83 c4 20             	add    $0x20,%esp
  803034:	5e                   	pop    %esi
  803035:	5f                   	pop    %edi
  803036:	5d                   	pop    %ebp
  803037:	c3                   	ret    
  803038:	39 d6                	cmp    %edx,%esi
  80303a:	75 d9                	jne    803015 <__umoddi3+0xf5>
  80303c:	2b 45 e8             	sub    -0x18(%ebp),%eax
  80303f:	1b 55 f4             	sbb    -0xc(%ebp),%edx
  803042:	eb d1                	jmp    803015 <__umoddi3+0xf5>
  803044:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  803048:	39 f2                	cmp    %esi,%edx
  80304a:	0f 82 18 ff ff ff    	jb     802f68 <__umoddi3+0x48>
  803050:	e9 1d ff ff ff       	jmp    802f72 <__umoddi3+0x52>
